Skip to content

Commit 99c6143

Browse files
authored
Merge branch 'master' into master
2 parents f83984a + fc3d004 commit 99c6143

File tree

60 files changed

+172955
-112
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+172955
-112
lines changed

Activity_Generator/code.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
"""ACTIVITY GENERATOR for Adafruit CLUE"""
2+
3+
import time
4+
import random
5+
from adafruit_clue import clue
6+
from things import activities
7+
from things import subjects
8+
9+
screen = clue.simple_text_display(text_scale=4, colors=(clue.WHITE,))
10+
11+
screen[1].text = "ACTIVITY"
12+
screen[2].text = "GENERATOR"
13+
screen.show()
14+
time.sleep(1.5)
15+
16+
screen[0].text = "make a"
17+
screen[2].text = "about"
18+
screen[1].color = clue.RED
19+
screen[3].color = clue.GREEN
20+
screen[4].color = clue.BLUE
21+
22+
activity = "???"
23+
subject_a = "???"
24+
subject_b = "???"
25+
two_subjects = True
26+
27+
def random_pick(items):
28+
index = random.randint(0, len(items)-1)
29+
return items[index]
30+
31+
while True:
32+
33+
if clue.button_a:
34+
activity = random_pick(activities)
35+
subject_a = random_pick(subjects)
36+
subject_b = random_pick(subjects)
37+
time.sleep(0.25)
38+
if clue.button_b:
39+
two_subjects = not two_subjects
40+
time.sleep(0.5)
41+
42+
screen[1].text = activity
43+
screen[3].text = subject_a
44+
45+
if two_subjects:
46+
screen[4].text = subject_b
47+
else:
48+
screen[4].text = ""
49+
50+
screen.show()

Activity_Generator/things.py

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
activities = [
2+
"DRAWING",
3+
"SONG",
4+
"STORY",
5+
"VIDEO",
6+
]
7+
8+
subjects = [
9+
"COMPUTER",
10+
"ALIEN",
11+
"LASER",
12+
"FOOD",
13+
"TREE",
14+
"DREAM",
15+
"WEATHER",
16+
"DOG",
17+
"CAT",
18+
"BIRD",
19+
"HORSE",
20+
"BLANKET",
21+
"TIME",
22+
"PLANT",
23+
"LEAF",
24+
"EAR",
25+
"HAND",
26+
"FEET",
27+
"TEETH",
28+
"PHONE",
29+
"SPACE",
30+
"ROBOT",
31+
"GHOST",
32+
"FUTURE",
33+
"PROBLEM",
34+
"MUSIC",
35+
"NOISE",
36+
"METAL",
37+
"ROCK",
38+
"AIR",
39+
"HOPE",
40+
"FEAR",
41+
"LOVE",
42+
"DANGER",
43+
"COOKIE",
44+
"BREAD",
45+
"WATER",
46+
"HAT",
47+
"ROUND",
48+
"SQUARE",
49+
"SUCCESS",
50+
"LIGHT",
51+
"RUNNING",
52+
"TALKING",
53+
"SLEEPING",
54+
"FLYING",
55+
"SINGING",
56+
"ACTING",
57+
]

Adafruit_Feather_Sense/feather_sense_sensor_demo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def normalized_rms(values):
3737

3838
print("\nFeather Sense Sensor Demo")
3939
print("---------------------------------------------")
40-
print("Proximity:", apds9960.proximity())
40+
print("Proximity:", apds9960.proximity)
4141
print("Red: {}, Green: {}, Blue: {}, Clear: {}".format(*apds9960.color_data))
4242
print("Temperature: {:.1f} C".format(bmp280.temperature))
4343
print("Barometric pressure:", bmp280.pressure)
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import time
2+
import board
3+
import digitalio
4+
import analogio
5+
from adafruit_clue import clue
6+
7+
# Turn off the NeoPixel
8+
clue.pixel.fill(0)
9+
10+
# Motor setup
11+
motor = digitalio.DigitalInOut(board.P2)
12+
motor.direction = digitalio.Direction.OUTPUT
13+
14+
# Soil sense setup
15+
analog = analogio.AnalogIn(board.P1)
16+
17+
def read_and_average(analog_in, times, wait):
18+
analog_sum = 0
19+
for _ in range(times):
20+
analog_sum += analog_in.value
21+
time.sleep(wait)
22+
return analog_sum / times
23+
24+
clue_display = clue.simple_text_display(title=" CLUE Plant", title_scale=1, text_scale=3)
25+
clue_display.show()
26+
27+
while True:
28+
# Take 100 readings and average them
29+
analog_value = read_and_average(analog, 100, 0.01)
30+
# Calculate a percentage (analog_value ranges from 0 to 65535)
31+
percentage = analog_value / 65535 * 100
32+
# Display the percentage
33+
clue_display[0].text = "Soil: {} %".format(int(percentage))
34+
# Print the values to the serial console
35+
print((analog_value, percentage))
36+
37+
if percentage < 50:
38+
motor.value = True
39+
clue_display[1].text = "Motor ON"
40+
clue_display[1].color = (0, 255, 0)
41+
time.sleep(0.5)
42+
43+
# always turn off quickly
44+
motor.value = False
45+
clue_display[1].text = "Motor OFF"
46+
clue_display[1].color = (255, 0, 0)
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# Bonsai Buckaroo + CLUE Plant Care Bot
2+
3+
import time
4+
import board
5+
from digitalio import DigitalInOut, Direction
6+
from analogio import AnalogIn
7+
from adafruit_clue import clue
8+
from adafruit_display_text import label
9+
import displayio
10+
import terminalio
11+
import pulseio
12+
13+
moist_level = 50 # adjust this value as needed for your plant
14+
15+
board.DISPLAY.brightness = 0.8
16+
clue.pixel.fill(0) # turn off NeoPixel
17+
18+
clue_display = displayio.Group(max_size=4)
19+
20+
# draw the dry plant
21+
dry_plant_file = open("dry.bmp", "rb")
22+
dry_plant_bmp = displayio.OnDiskBitmap(dry_plant_file)
23+
dry_plant_sprite = displayio.TileGrid(dry_plant_bmp, pixel_shader=displayio.ColorConverter())
24+
clue_display.append(dry_plant_sprite)
25+
26+
# draw the happy plant on top (so it can be moved out of the way when needed)
27+
happy_plant_file = open("happy.bmp", "rb")
28+
happy_plant_bmp = displayio.OnDiskBitmap(happy_plant_file)
29+
happy_plant_sprite = displayio.TileGrid(happy_plant_bmp, pixel_shader=displayio.ColorConverter())
30+
clue_display.append(happy_plant_sprite)
31+
32+
# Create text
33+
# first create the group
34+
text_group = displayio.Group(max_size=3, scale=3)
35+
# Make a label
36+
title_label = label.Label(terminalio.FONT, text="CLUE Plant", color=0x00FF22)
37+
# Position the label
38+
title_label.x = 10
39+
title_label.y = 4
40+
# Append label to group
41+
text_group.append(title_label)
42+
43+
soil_label = label.Label(terminalio.FONT, text="Soil: ", color=0xFFAA88, max_glyphs=10)
44+
soil_label.x = 4
45+
soil_label.y = 64
46+
text_group.append(soil_label)
47+
48+
motor_label = label.Label(terminalio.FONT, text="Motor off", color=0xFF0000, max_glyphs=9)
49+
motor_label.x = 4
50+
motor_label.y = 74
51+
text_group.append(motor_label)
52+
53+
clue_display.append(text_group)
54+
board.DISPLAY.show(clue_display)
55+
56+
motor = DigitalInOut(board.P2)
57+
motor.direction = Direction.OUTPUT
58+
59+
buzzer = pulseio.PWMOut(board.SPEAKER, variable_frequency=True)
60+
buzzer.frequency = 1000
61+
62+
sense_pin = board.P1
63+
analog = AnalogIn(board.P1)
64+
65+
def read_and_average(ain, times, wait):
66+
asum = 0
67+
for _ in range(times):
68+
asum += ain.value
69+
time.sleep(wait)
70+
return asum / times
71+
72+
time.sleep(5)
73+
74+
while True:
75+
# take 100 readings and average them
76+
aval = read_and_average(analog, 100, 0.01)
77+
# calculate a percentage (aval ranges from 0 to 65535)
78+
aperc = aval / 65535 * 100
79+
# display the percentage
80+
soil_label.text = "Soil: {} %".format(int(aperc))
81+
print((aval, aperc))
82+
83+
if aperc < moist_level:
84+
happy_plant_sprite.x = 300 # move the happy sprite away
85+
time.sleep(1)
86+
motor.value = True
87+
motor_label.text = "Motor ON"
88+
motor_label.color = 0x00FF00
89+
buzzer.duty_cycle = 2**15
90+
time.sleep(0.5)
91+
92+
# always turn off quickly
93+
motor.value = False
94+
motor_label.text = "Motor off"
95+
motor_label.color = 0xFF0000
96+
buzzer.duty_cycle = 0
97+
98+
if aperc >= moist_level:
99+
happy_plant_sprite.x = 0 # bring back the happy sprite

Buckaroo_Plant_Care_Bot/dry.bmp

113 KB
Binary file not shown.

Buckaroo_Plant_Care_Bot/happy.bmp

113 KB
Binary file not shown.

0 commit comments

Comments
 (0)