This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from shapes import Triangle, Rectangle, Oval | |
rect1 = Rectangle() | |
rect1.set_width(200) | |
rect1.set_height(100) | |
rect1.set_color("blue") | |
rect1.set_x(0) | |
rect1.set_y(0) | |
rect1.draw() | |
rect2 = Rectangle() | |
rect2.set_width(50) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
amber.on() | |
sleep(2) | |
amber.off() | |
sleep(2) | |
red.on() | |
sleep(2) | |
red.off() | |
sleep(2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import time | |
import automationhat | |
time.sleep(0.1) # short pause after ads1015 class creation recommended | |
print(""" | |
Press CTRL+C to exit. | |
""") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Test font size to determine the maximum number of characters per line and should match the default font used in draw_text | |
test_font = inkyphat.ImageFont.truetype(inkyphat.fonts.AmaticSC,20) | |
w, h = test_font.getsize("1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ") | |
max_char = int((212/(w/36))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import inkyphat | |
from random import randint | |
def draw_text(position, text, font=None, colour=inkyphat.BLACK): | |
x, y = position | |
x = x+5 | |
if font is None: | |
font = inkyphat.ImageFont.truetype(inkyphat.fonts.AmaticSC,20) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from gpiozero import LED | |
from time import sleep | |
green = LED(14) | |
amber = LED(15) | |
red = LED(18) | |
list = [red,amber,green] | |
while True: | |
choice = random.choice(list) | |
choice.on() | |
sleep(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from gpiozero import LED | |
from time import sleep | |
green = LED(14) | |
amber = LED(15) | |
red = LED(18) | |
green.on() | |
sleep(2) | |
green.off() | |
sleep(2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from gpiozero import Button | |
from gpiozero import LED | |
from time import * | |
import time | |
import random | |
button = Button(21) | |
green =LED(14) | |
yellow=LED(15) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from gpiozero import MotionSensor | |
from gpiozero import LED | |
from time import sleep | |
import random | |
green = LED(20) | |
red = LED(21) | |
sensor = MotionSensor(4) | |
while True: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from gpiozero import MotionSensor | |
sensor = MotionSensor(4) | |
while True: | |
if sensor.motion_detected: | |
print ("Spotted you move") |
NewerOlder