Skip to content

Commit 484332e

Browse files
authored
Merge pull request #161 from ladyada/master
bubbblez
2 parents 75f565f + 9538c01 commit 484332e

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

Crickits/bubble_machine/main.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# CircuitPython 3.0 CRICKIT demo
2+
from adafruit_seesaw.seesaw import Seesaw
3+
from adafruit_seesaw.pwmout import PWMOut
4+
from adafruit_motor import servo, motor
5+
from busio import I2C
6+
import board
7+
import time
8+
9+
i2c = I2C(board.SCL, board.SDA)
10+
ss = Seesaw(i2c)
11+
12+
print("Bubble machine!")
13+
14+
SERVOS = True
15+
DCMOTORS = True
16+
17+
#################### Create 4 Servos
18+
servos = []
19+
if SERVOS:
20+
for ss_pin in (17, 16, 15, 14):
21+
pwm = PWMOut(ss, ss_pin)
22+
pwm.frequency = 50
23+
_servo = servo.Servo(pwm)
24+
_servo.angle = 90 # starting angle, middle
25+
servos.append(_servo)
26+
27+
#################### Create 2 DC motors
28+
motors = []
29+
if DCMOTORS:
30+
for ss_pin in ((18, 19), (22, 23)):
31+
pwm0 = PWMOut(ss, ss_pin[0])
32+
pwm1 = PWMOut(ss, ss_pin[1])
33+
_motor = motor.DCMotor(pwm0, pwm1)
34+
motors.append(_motor)
35+
36+
while True:
37+
print("servo down")
38+
servos[0].angle = 180
39+
time.sleep(1)
40+
print("fan on")
41+
motors[0].throttle = 1
42+
time.sleep(3)
43+
print("fan off")
44+
time.sleep(1)
45+
motors[0].throttle = 0
46+
print("servo up")
47+
servos[0].angle = 0
48+
time.sleep(1)

0 commit comments

Comments
 (0)