Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • justinmass2001/iotproject
1 result
Show changes
Commits on Source (2)
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
form ctypes.wintypes import RGB
from ctypes.wintypes import RGB
from time import sleep
import RPi.GPIO as GPIO
from colour import Color
......@@ -12,6 +12,7 @@ class RGBA():
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)
......@@ -36,15 +37,16 @@ class RGBA():
print( r, g, b )
# 0 - 100 for colours module ( any error to use this code...)
''' def setRGB(self, rgb):
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)
......
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
Any python packages installing to environment error:
sudo aptget install colour --break-system-packages
Create a Venv File:
python -m venv iotcloud
......
......@@ -13,6 +13,7 @@ def hello_world():
"username": "justin",
"env": "labs",
"avatar": "https://media.licdn.com/dms/image/D5603AQGqSYfbrnkjcw/profile-displayphoto-shrink_200_200/0/1694890248719?e=1720051200&v=beta&t=M6ZsyUoBIQ8fpaswZe6aCld0oOmrala4dKPRt2m4v98"
# avatar link my linkedin profile image URL.
}
return render_template('helloworld.html', data = d)
......
This diff is collapsed.