A simple way to start the Raspberry Pi programming way is try to programming a Raspberry Pi. Now I have created this simple tutorial. You can follow the simple passages and make a simple RGB wireless lamp.
All the components are a RGB led, comune cathode, three resistences (120 Ohm + 120 Ohm + 100 Ohm), a pinplug for Raspberry Pi GPiO, and a piece of perfboard.
The circuit is very simple. You can also use a breadboard and some jumper cable.
Now you are a RGB circuit for Raspberry Pi. Plug the circuit on GPiO in this position.
The Blue pin in the 25
The Green pin in the 24
The Red pin in the 23
Pay attention of the numbers of pin. In this project we use a GPIO pin number. for thi reason we follow the GPIO numeration. Like in the image, you can view the pin number and the GPIO number. The RGB led use the GPIO pins 23, 24 and 25. Also the RGB led use the GND pin between the pins 24 and 25.
Please double-check before start your system. You can burn Raspberry Pi.
Now you can run the Raspberry Pi. Connect by Terminal if you use MAC OSX or Linux. If you use a Windows system, you can download putty (www.putty.org). Connect by a ssh protocol, and use the terminal for write the Python program and for command the RGB led light.
An important feature of Raspberry Pi is the presence of Python. Now Raspbian have inside a version of Python. You can test the presence of Python in your Raspbian system by this command:
When you write this command if the system have installed Python write on the screen the Python version.
Type on the terminal:
sudo nano rgb.py
After this put the code in the terminal window.
(see the py file)
import RPi.GPIO as GPIO
RED = 25
GREEN = 24
BLUE = 23
request = raw_input(“RGB—>”)
if (len(request) == 3):
Push CTRL + X button and save the rgb.py file.
Now you can start the program.
sudo python rgb.py
You can read RGB-->
Now use 0 for OFF the color and 1 for ON color.
Use first number for Red, second number for Green and third for Blue.
For blue write 001 and after click enter
For green write 010 and after click enter
For red write 100 and after click enter
The fun comes when you start mixing colors.
Try 101 click enter and see the color.