embedded system,arduino,raspberry pi,msp430f169, ARM7

Wednesday, December 18, 2013

On 11:18 PM by array operation   No comments
We did a very simple experiment on interfacing a single LED to the GPIO of Raspberry Pi.

The basic circuit diagram is shown below:



Here, we used GPIO8 of the Raspberry Pi and connected it to the LED through a current limiting resistor of 200E.

The python code to blink the LED ON/OFF continuously is shown below:

import RPi.GPIO as GPIO
import time
pinNum = 8
GPIO.setmode(GPIO.BCM) #numbering scheme that corresponds to breakout board and pin layout
GPIO.setup(pinNum,GPIO.OUT) #replace pinNum with whatever pin you used, this sets up that pin as an output
#set LED to flash forever
while True:
  GPIO.output(pinNum,GPIO.HIGH)
  time.sleep(0.5)
  GPIO.output(pinNum,GPIO.LOW) 
  time.sleep(0.5)


To run the above code, save it in any file, say led.py using any text editor. Once saved, run this command to see the LED in action:
sudo python led.py




Change with the different GPIO pins and have a fun...................