Closed qyc206 closed 3 years ago
Pi connections to OLED screen - will try to not use the same connections for the LED
RGB LED adafruit website: https://www.adafruit.com/product/302 RGB LED datasheet: https://cdn-shop.adafruit.com/datasheets/FD-5WSRGB-A.PDF
From picture above: 4=blue, 3=green, 1=common/ground, 2=red
Test code is the following. Needed to make sure I could connect two LEDs and change their color simultaneously. Now I will change LED colors using the shift registers.
References: https://www.instructables.com/Using-a-RPi-to-Control-an-RGB-LED/
import RPi.GPIO as GPIO
import time
def blink(pin):
GPIO.output(pin, GPIO.HIGH)
def turnOff(pin):
GPIO.output(pin, GPIO.LOW)
def redOn():
blink(rpin)
def redOff():
turnOff(rpin)
def blueOn():
blink(bpin)
def blueOff():
turnOff(bpin)
def greenOn():
blink(gpin)
def greenOff():
turnOff(gpin)
def yellowOn():
blink(rpin)
blink(gpin)
def yellowOff():
turnOff(rpin)
turnOff(gpin)
def whiteOn():
blink(rpin)
blink(gpin)
blink(bpin)
def whiteOff():
turnOff(rpin)
turnOff(gpin)
turnOff(bpin)
rpin=11
gpin=13
bpin=15
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(rpin, GPIO.OUT) #GPIO12, pin 32
GPIO.setup(gpin, GPIO.OUT)
GPIO.setup(bpin, GPIO.OUT)
turnOff(rpin)
turnOff(gpin)
turnOff(bpin)
try:
while True:
redOn()
time.sleep(1)
redOff()
time.sleep(1)
blueOn()
time.sleep(1)
blueOff()
time.sleep(1)
greenOn()
time.sleep(1)
greenOff()
time.sleep(1)
whiteOn()
time.sleep(1)
whiteOff()
time.sleep(1)
yellowOn()
time.sleep(1)
yellowOff()
time.sleep(1)
except KeyboardInterrupt:
turnOff(rpin)
turnOff(bpin)
turnOff(gpin)
print("interrupted")
Proof test code works https://user-images.githubusercontent.com/58012214/113186370-93707c80-9225-11eb-9dd1-6589dcbe06f8.MP4
Gathering Resources: Arduino Tutorial: https://learn.adafruit.com/adafruit-arduino-lesson-4-eight-leds/the-74hc595-shift-register Adafruit 74HC595 purchase page: https://www.adafruit.com/product/450 Adafruit 74HC595 datasheet: https://cdn-shop.adafruit.com/datasheets/sn74hc595.pdf
OLED pin: GPIO12 RLED pin: GPIO11 GLED pin: GPIO13 BLED pin: GPIO15
Shift register tutorials: https://thinkingofpi.com/getting-started/raspberry-pi-shift-register/
will attach picture when my computer works
Video to help get started: https://www.youtube.com/watch?v=hqVpxCPFaQk&ab_channel=CreativeStuff
clean schematic of 24 LEDs with 3 shift registers: https://www.electronics-lab.com/project/24-leds-bargraph-display-using-74hc595-shift-register/
Was able to get the red LED wave working with the current circuit schematic and code.