loading

Step 4: Write the program

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

GPIO.setmode(GPIO.BCM)

RED = 25

GREEN = 24

BLUE = 23

GPIO.setup(RED,GPIO.OUT)

GPIO.output(RED,0)

GPIO.setup(GREEN,GPIO.OUT)

GPIO.output(GREEN,0)

GPIO.setup(BLUE,GPIO.OUT)

GPIO.output(BLUE,0)

try:

while (True):

request = raw_input(“RGB—>”)

if (len(request) == 3):

GPIO.output(RED,int(request[0]))

GPIO.output(GREEN,int(request[1]))

GPIO.output(BLUE,int(request[2]))

except KeyboardInterrupt:

GPIO.cleanup()

Push CTRL + X button and save the rgb.py file.

About This Instructable

3,497views

31favorites

License:

More by masteruan:House's Monitoring Consumption With Arduino UNO Arduino 101 Bluethooth IOS Pulse Sensor C51 4-Bit Clock Kit 3D Printed Enclosure 
Add instructable to: