# from machine import Pin
# import time
# ledR = Pin(27, Pin.OUT)
# ledO = Pin(26, Pin.OUT)
# ledG = Pin(22, Pin.OUT)
# while True:
# ledR.value(1)
# time.sleep(1)
# ledR.value(0)
# time.sleep(1)
# ledO.value(1)
# time.sleep(1)
# ledO.value(0)
# time.sleep(1)
# ledG.value(1)
# time.sleep(1)
# ledG.value(0)
# time.sleep(1)
# from machine import Pin
# import time
# ledG = Pin(22, Pin.OUT)
# button = Pin(10, Pin.IN)
# led_status = False
# while True:
# if button.value() == 1:
# led_status = not led_status
# ledG.value(led_status)
# else:
# ledG.value(led_status)
# from machine import Pin
# from gpiozero import Buzzer
# from time import sleep
# buzzer = Buzzer(1)
# button = Pin(2, Pin.IN)
# while True:
# if button.value() == 1:
# buzzer.on()
# sleep(1)
# else:
# buzzer.off()
# sleep(1)
import RPi.GPIO as GPIO
from time import sleep
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
redPin = 21
greenPin = 20
bluePin = 19
GPIO.setup(redPin,GPIO.OUT)
GPIO.setup(greenPin,GPIO.OUT)
GPIO.setup(bluePin,GPIO.OUT)
def turnOff():
GPIO.output(redPin,GPIO.HIGH)
GPIO.output(greenPin,GPIO.HIGH)
GPIO.output(bluePin,GPIO.HIGH)
def white():
GPIO.output(redPin,GPIO.LOW)
GPIO.output(greenPin,GPIO.LOW)
GPIO.output(bluePin,GPIO.LOW)
def red():
GPIO.output(redPin,GPIO.LOW)
GPIO.output(greenPin,GPIO.HIGH)
GPIO.output(bluePin,GPIO.HIGH)
def green():
GPIO.output(redPin,GPIO.HIGH)
GPIO.output(greenPin,GPIO.LOW)
GPIO.output(bluePin,GPIO.HIGH)
def blue():
GPIO.output(redPin,GPIO.HIGH)
GPIO.output(greenPin,GPIO.HIGH)
GPIO.output(bluePin,GPIO.LOW)
def yellow():
GPIO.output(redPin,GPIO.LOW)
GPIO.output(greenPin,GPIO.LOW)
GPIO.output(bluePin,GPIO.HIGH)
def purple():
GPIO.output(redPin,GPIO.LOW)
GPIO.output(greenPin,GPIO.HIGH)
GPIO.output(bluePin,GPIO.LOW)
def lightBlue():
GPIO.output(redPin,GPIO.HIGH)
GPIO.output(greenPin,GPIO.LOW)
GPIO.output(bluePin,GPIO.LOW)
while True:
turnOff()
sleep(1)
white()
sleep(1)
red()
sleep(1)
green()
sleep(1)
blue()
sleep(1)
yellow()
sleep(1)
purple()
sleep(1)
lightBlue()
sleep(1)