Skip to content

Commit 30807b4

Browse files
committed
2 parents b1dc035 + e846a03 commit 30807b4

File tree

2 files changed

+60
-8
lines changed

2 files changed

+60
-8
lines changed

PMS5003_Air_Quality_Sensor/PMS5003_CircuitPython/main.py renamed to PMS5003_Air_Quality_Sensor/PMS5003_CircuitPython/PMS5003_example.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
1-
import board
2-
import busio
3-
from digitalio import DigitalInOut, Direction
4-
51
try:
62
import struct
73
except ImportError:
84
import ustruct as struct
95

10-
led = DigitalInOut(board.D13)
11-
led.direction = Direction.OUTPUT
12-
13-
# Connect the Sensor's TX pin to the board's RX pin
6+
# Connect the sensor TX pin to the board/computer RX pin
7+
# For use with a microcontroller board:
8+
import board
9+
import busio
1410
uart = busio.UART(board.TX, board.RX, baudrate=9600)
1511

12+
# For use with Raspberry Pi/Linux:
13+
# import serial
14+
# uart = serial.Serial("/dev/ttyS0", baudrate=9600, timeout=0.25)
15+
16+
# For use with USB-to-serial cable:
17+
# import serial
18+
# uart = serial.Serial("/dev/ttyUSB0", baudrate=9600, timeout=0.25)
19+
1620
buffer = []
1721

1822
while True:
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Turtle Gizmo Snowflakes
2+
#==| Turtle Gizmo Setup start |========================================
3+
import time
4+
from random import randint
5+
import board
6+
import busio
7+
import displayio
8+
from adafruit_st7789 import ST7789
9+
from adafruit_turtle import turtle
10+
displayio.release_displays()
11+
spi = busio.SPI(board.SCL, MOSI=board.SDA)
12+
display_bus = displayio.FourWire(spi, command=board.TX, chip_select=board.RX)
13+
display = ST7789(display_bus, width=240, height=240, rowstart=80,
14+
backlight_pin=board.A3, rotation=180)
15+
turtle = turtle(display)
16+
#==| Turtle Gizmo Setup end |=========================================
17+
18+
def draw_arm():
19+
turtle.pendown()
20+
for angle, length in arm_data:
21+
turtle.forward(length)
22+
turtle.left(angle)
23+
turtle.forward(length)
24+
turtle.backward(length)
25+
turtle.right(2*angle)
26+
turtle.forward(length)
27+
turtle.backward(length)
28+
turtle.left(angle)
29+
turtle.penup()
30+
31+
def draw_flake(arms):
32+
turtle.penup()
33+
turtle.home()
34+
turtle.clear()
35+
angle = 0
36+
delta_angle = 360 // arms
37+
for _ in range(arms):
38+
turtle.home()
39+
turtle.setheading(angle)
40+
draw_arm()
41+
angle += delta_angle
42+
turtle.penup()
43+
turtle.home()
44+
45+
while True:
46+
arm_data = [(randint(30, 80), randint(10, 40)) for _ in range(5)]
47+
draw_flake(randint(5, 8)) #adjust number of arms here
48+
time.sleep(5)

0 commit comments

Comments
 (0)