contolling LED bulb using raspberry pi 3
First experiment using led:
Hardware Requirements
LED bulb
1k ohm resistor
2x female to male jumper wire
breadboard
anode(big leg) of the LED is connected through resistor
in gpio pin 17 and cathode(small leg) of the led is connected
to ground(GND) of the gpio pin
python program for control the led:
- python has new gpiozero library to control the gpio pins according to the speific python programming paradigm.
The following python program can be control the led bulb.
- from gpiozero import LED
- from time import sleep
- led=LED(17)
- while 1:
- led.on()
- sleep(1)
- led.off()
- sleep()
in the above program LED module is imported from gpiozero library then sleep module is imported from time library for the purpose of led blink. led=LED(17) this specifies the led bulb connected to the gpio 17, while 1: this line tells the condition is always true and running the program until the user terminate it.
0 comments:
Post a Comment