diff --git a/Raspberrypi/rgbcolor/255_valu.py b/Raspberrypi/rgbcolor/255_valu.py deleted file mode 100644 index a9e4ad75536eae4717fe346b54f716d495e86bc1..0000000000000000000000000000000000000000 --- a/Raspberrypi/rgbcolor/255_valu.py +++ /dev/null @@ -1,32 +0,0 @@ -from time import sleep -import RPi.GPIO as GPIO - -class RGBA(): - def __init__(self, r, g, b): - GPIO.setmode(GPIO.BCM) - channel = [r, g, b] - for c in channel: - GPIO.setup(c, GPIO.OUT) - self.r = GPIO.PWM (r, 120) # channel = 12 frequency = 60Hz - self.g = GPIO.PWM (g, 120) # channel = 13 frequency = 60Hz - self.b = GPIO.PWM (b, 120) # channel = 19 frequency = 60Hz - - self.r.start(0) - self.g.start(0) - self.b.start(0) - - # 0 -255 for r, g, b - def setColor(self, r, g, b): - r = 100 - ( r / 255 ) * 100 - g = 100 - ( g / 255 ) * 100 - b = 100 - ( b / 255 ) * 100 - print(r, g, b) - - self.r.ChangeDutyCycle(r) - self.g.ChangeDutyCycle(g) - self.b.ChangeDutyCycle(b) - -led = RGBA (12, 13, 19) -led.setColor ( 70, 34, 84 ) -sleep(3) -GPIO.cleanup() \ No newline at end of file diff --git a/Raspberrypi/rgbcolor/color.py b/Raspberrypi/rgbcolor/color.py deleted file mode 100644 index fd508cc0752413226688d0c70160233f8aa793fc..0000000000000000000000000000000000000000 --- a/Raspberrypi/rgbcolor/color.py +++ /dev/null @@ -1,66 +0,0 @@ -from ctypes.wintypes import RGB -from time import sleep -import RPi.GPIO as GPIO -from colour import Color - -class RGBA(): - def __init__(self, r, g, b): - GPIO.setmode(GPIO.BCM) - channel = [r, g, b] - for c in channel: - GPIO.setup(c, GPIO.OUT) - self.r = GPIO.PWM(r, 120) # channel = 12 frequency = 60Hz - self.g = GPIO.PWM(g, 120) # channel = 12 frequency = 60Hz - self.b = GPIO.PWM(b, 120) # channel = 12 frequency = 60Hz - - self.r.start(0) - self.g.start(0) - self.b.start(0) - -# 0 - 225 for (r, g, b) - - def setRGBColor(self, r, g, b): - r = 100 - (r / 225) * 100 - g = 100 - (r / 225) * 100 - b = 100 - (r / 225) * 100 - print( r, g, b ) - - self.r.ChangeDutyCycle(int(r)) - self.g.ChangeDutyCycle(int(g)) - self.b.ChangeDutyCycle(int(b)) - -# 0 - 100 for colours module - def setRGB(self, rgb): - self.r.ChangeDutyCycle(int(rgb[0])) - self.g.ChangeDutyCycle(int(rgb[1])) - self.b.ChangeDutyCycle(int(rgb[2])) - print( r, g, b ) - -# 0 - 100 for colours module ( any error to use this code...) - def setRGB(self, rgb): - r = abs(rgb[0] * 100 - 100 ) - g = abs(rgb[1] * 100 - 100 ) - b = abs(rgb[2] * 100 - 100 ) - print(r, g, b) - - self.r.ChangeDutyCycle(int(r)) - self.g.ChangeDutyCycle(int(g)) - self.b.ChangeDutyCycle(int(b)) - -# led = RGBA(12,13,19) -# led.setRGBColor(255,0,0) # type any color code to blink -# sleep(10) -# GPIO.cleanup() - -#led = RGBA(12,13,19) -# led.setRGB(Color(input("Enter Any Color...")).rgb) # Enter any color code to blink -# sleep(10) -# GPIO.cleanup() -led = RGBA(12, 13, 19) -while True: - for c in Color("rgb").range_to(Color("blue") ,100): - led.setRGB(c.rgb) - sleep(0.1) - for c in Color("blue").range_to(Color("red") ,100): - led.setRGB(c.rgb) - sleep(0.1) \ No newline at end of file diff --git a/Raspberrypi/rgbcolor/input.py b/Raspberrypi/rgbcolor/input.py deleted file mode 100644 index 66ed35b177589fca7820274830d48b5ecfb1ed9e..0000000000000000000000000000000000000000 --- a/Raspberrypi/rgbcolor/input.py +++ /dev/null @@ -1,52 +0,0 @@ -from time import sleep -import RPi.GPIO as GPIO -from colour import Color -import math - -class RGBA(): - def __init__(self, r, g, b): - GPIO.setmode(GPIO.BCM) - channel = [r, g, b] - for c in channel: - GPIO.setup(c, GPIO.OUT) - self.r = GPIO.PWM (r, 120) # channel = 12 frequency = 60Hz - self.g = GPIO.PWM (g, 120) # channel = 13 frequency = 60Hz - self.b = GPIO.PWM (b, 120) # channel = 19 frequency = 60Hz - - self.r.start(0) - self.g.start(0) - self.b.start(0) - - # 0 -255 for r, g, b - def setRGBColor(self, r, g, b): - r = 100 - ( r / 255 ) * 100 - g = 100 - ( g / 255 ) * 100 - b = 100 - ( b / 255 ) * 100 - print(r, g, b) - - self.r.ChangeDutyCycle(int(r)) - self.g.ChangeDutyCycle(int(g)) - self.b.ChangeDutyCycle(int(b)) - - - # 0 - 100 ( For colours module ) - def setRGB(self, rgb): - r = abs (rgb[0] * 100 - 100 ) - g = abs (rgb[1] * 100 - 100 ) - b = abs (rgb[2] * 100 - 100 ) - print(r, g, b) - self.r.ChangeDutyCycle(int(r)) - self.g.ChangeDutyCycle(int(g)) - self.b.ChangeDutyCycle(int(b)) - -led = RGBA (12, 13, 19) -while True: - try: - led.setRGB(Color(input("Enter Any Color: ")).rgb) - except KeyboardInterrupt: - # Handle the cleanup here - GPIO.cleanup() # Reset the GPIO pins - print("Cleaned up GPIO...") - break - # finally: - # print("Exit the Loops...") \ No newline at end of file diff --git a/Raspberrypi/rgbcolor/type0-7color.py b/Raspberrypi/rgbcolor/type0-7color.py deleted file mode 100644 index f56ff7afb5d7dfcc026c2fda3b4379f600af5408..0000000000000000000000000000000000000000 --- a/Raspberrypi/rgbcolor/type0-7color.py +++ /dev/null @@ -1,30 +0,0 @@ -import RPi.GPIO as GPIO -from time import sleep - -#GPIO.cleanup() -GPIO.setmode(GPIO.BCM) -channel = [12, 13, 19] -for c in channel: - GPIO.setup(c, GPIO.OUT) -#GPIO.output(channel, GPIO.HIGH) -#GPIO.output(channel, GPIO.LOW) - -try: - while True: - try: - i = input("Enter a number between 0-7...") - i = int(i) - if i < 8 or i >=8: - print("Invalid range of input... Try again...") - continue - rgb = format(i, '03b') - for i, c in enumerate(channel): - print(i, c, rgb[i]) - GPIO.output(c, not bool(int(rgb[i]))) - - except ValueError: - print("Invalid Input, Try again...") - -except KeyboardInterrupt: - GPIO.cleanup() - print("Quitting...") \ No newline at end of file