According to Wikipedia,
The Raspberry Pi is a credit card-sized single-board computer developed in the UK by the Raspberry Pi Foundation with the intention of promoting the teaching of basic computer science in schools.
According to me,
It's the bigger brother of Arduino, in terms of memory and performance but in a certain contextAlthough the RPi functions a lot as a computer(which it is!), it has also got the 40 GPIO pins, much similar to the digital pins of the Arduino. To be frank, there are lots of differences between them too. But, since we are more interested in the application of both the MCU's in sensing the environment and manipulating them, we'll confine ourselves to the input/output capabilities.
That's enough talk about RPi. For more info, you may simply search for "Raspberry Pi" on Google and you'll be saturated with information! :P
So, let's begin.
What this project does?
Blink an LED 20 times using the RPi.
Let's know the basics!
Well, you should be knowing what an LED is and what minimum current should pass through it. For me, it was around 20 mA. Do refer to your LED Datasheet for more info. Also, keep in mind that messing up even a little bit can damage your RPi, which is a little more heavier on the pocket as compared to the Arduino!
NOTE:
The GPIO Pins on the RPi, can be fully controlled via Python. So, it's recommended that you play around with some Python code and get acquainted with the Python environment.
The GPIO Pins on the RPi, can be fully controlled via Python. So, it's recommended that you play around with some Python code and get acquainted with the Python environment.
Here are some sites to get you started if you have no or zero knowledge of the Python environment.
1. An LED
2. Raspberry Pi and accessories. (Including monitor, keyboard and mouse)
3. Jumpers
4. One 330 OHM resistor
5. Breadboard
Procedure:
1. Start up RPi and open LeafPad.
2. Type in the code(scroll down to find the code) and save the file with the name: "blink,py".
Save this file in the root folder, i.e, [/home/pi]
3. Connect all the components as shown below:
Connect:
- GPIO PIN17 [PIN No.11] to the LED's +ve pin
- GPIO GND[PIN No. 6] to the LED's -ve pin via resistor.
4. Open LXTerminal and type the command:
sudo python blink.py
and press enter.
5. You should see the LED flash. After blinking 20 times, the GPIO pins return to normal state.
Python Code:
#Code by electro.nitishdash.com import RPi.GPIO as GPIO import time def blink(pin): GPIO.output(pin,GPIO.HIGH) time.sleep(1) GPIO.output(pin,GPIO.LOW) time.sleep(1) return # to use Raspberry Pi board pin numbers GPIO.setmode(GPIO.BOARD) # set up GPIO output pin GPIO.setup(11, GPIO.OUT) #to blink GPIO17 20 times for i in range(0,20): blink(11) GPIO.cleanup()
Video:
Coming soon.....
Downloads:
1. blink.py
2. Breadboard schematics
3. Pin layout (Model B+)
Homework for you!
1. Try adding 3 leds of different colours and light them up one by one after a small interval.
Wow! That works amazingly.... Nobody would have ever thought that the world would see that small a computer!
ReplyDeleteGood Work. Will surely share all your articles with my circles and friends.
Have a good day!
-John
Thanks a lot for your comment John. I am really happy that you liked it.
DeleteYes, the RPi is a beautiful tiny computer. I'd recommend you to check out other MCUs like Beaglebone, etc.
Sharing is caring bro! Thanks.