casychow / DesktopPet_Eui

A small, mobile desk robot that helps alleviate the physical, emotional, and mental problems frequently faced by desk workers. This is my NYU Tandon Senior Design Project.
0 stars 0 forks source link

testing light subsystem #7

Closed qyc206 closed 3 years ago

qyc206 commented 3 years ago
casychow commented 3 years ago

Pi connections to OLED screen - will try to not use the same connections for the LED image

RGB LED adafruit website: https://www.adafruit.com/product/302 RGB LED datasheet: https://cdn-shop.adafruit.com/datasheets/FD-5WSRGB-A.PDF

image From picture above: 4=blue, 3=green, 1=common/ground, 2=red

casychow commented 3 years ago

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

casychow commented 3 years ago

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

casychow commented 3 years ago

Shift register tutorials: https://thinkingofpi.com/getting-started/raspberry-pi-shift-register/

will attach picture when my computer works

qyc206 commented 3 years ago

Video to help get started: https://www.youtube.com/watch?v=hqVpxCPFaQk&ab_channel=CreativeStuff

qyc206 commented 3 years ago

clean schematic of 24 LEDs with 3 shift registers: https://www.electronics-lab.com/project/24-leds-bargraph-display-using-74hc595-shift-register/

casychow commented 3 years ago

Was able to get the red LED wave working with the current circuit schematic and code. IMG_34715B86FD6C-1

image image