Tuesday, May 19, 2015

Control an LED to be ON/OFF

1. Connect an LED and a resistor to the Raspberry Pi as instructions.

2. Connect the power to GPIO 4 pin of Raspberry Pi instead of 3.3V.

3. Type the commands below:

sudo python

>>> import RPi.GPIO as GPIO
>>> GPIO.setmode(GPIO.BCM)
>>> GPIO.setup(4,GPIO.OUT)
>>> GPIO.output(4,1)

 LED is ON.
 >>> GPIO.output(4,0)
LED is OFF.

No comments:

Post a Comment