File tree Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Original file line number Diff line number Diff line change
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 )
You can’t perform that action at this time.
0 commit comments