File tree 7 files changed +103
-0
lines changed
7 files changed +103
-0
lines changed Original file line number Diff line number Diff line change
1
+ import time
2
+ from adafruit_circuitplayground .express import cpx
3
+
4
+ while True :
5
+ x , y , z = cpx .acceleration
6
+ print (x , y , z )
7
+
8
+ time .sleep (0.1 )
Original file line number Diff line number Diff line change
1
+ # CircuitPython demo - NeoPixel
2
+
3
+ import time
4
+ from adafruit_circuitplayground .express import cpx
5
+
6
+
7
+ # The number of pixels in the strip
8
+ numpix = 10
9
+
10
+ def wheel (pos ):
11
+ # Input a value 0 to 255 to get a color value.
12
+ # The colours are a transition r - g - b - back to r.
13
+ if (pos < 0 ) or (pos > 255 ):
14
+ return (0 , 0 , 0 )
15
+ if pos < 85 :
16
+ return (int (pos * 3 ), int (255 - (pos * 3 )), 0 )
17
+ elif pos < 170 :
18
+ pos -= 85
19
+ return (int (255 - pos * 3 ), 0 , int (pos * 3 ))
20
+ #else:
21
+ pos -= 170
22
+ return (0 , int (pos * 3 ), int (255 - pos * 3 ))
23
+
24
+ def rainbow_cycle (wait ):
25
+ for j in range (255 ):
26
+ for i in range (cpx .pixels .n ):
27
+ idx = int ((i * 256 / len (cpx .pixels )) + j )
28
+ cpx .pixels [i ] = wheel (idx & 255 )
29
+ cpx .pixels .show ()
30
+ time .sleep (wait )
31
+
32
+ cpx .pixels .auto_write = False
33
+ cpx .pixels .brightness = 0.3
34
+ while True :
35
+ rainbow_cycle (0.001 ) # rainbowcycle with 1ms delay per step
Original file line number Diff line number Diff line change
1
+ from adafruit_circuitplayground .express import cpx
2
+
3
+ while True :
4
+ if cpx .shake (shake_threshold = 20 ):
5
+ print ("Shake detected!" )
Original file line number Diff line number Diff line change
1
+ from adafruit_circuitplayground .express import cpx
2
+
3
+ # Set to check for single-taps.
4
+ cpx .detect_taps = 1
5
+ tap_count = 0
6
+
7
+ # We're looking for 2 single-taps before moving on.
8
+ while tap_count < 2 :
9
+ if cpx .tapped :
10
+ tap_count += 1
11
+ print ("Reached 2 single-taps!" )
12
+
13
+ # Now switch to checking for double-taps
14
+ tap_count = 0
15
+ cpx .detect_taps = 2
16
+
17
+ # We're looking for 2 double-taps before moving on.
18
+ while tap_count < 2 :
19
+ if cpx .tapped :
20
+ tap_count += 1
21
+ print ("Reached 2 double-taps!" )
22
+ print ("Done." )
Original file line number Diff line number Diff line change
1
+ from adafruit_circuitplayground .express import cpx
2
+
3
+ cpx .detect_taps = 1
4
+
5
+ while True :
6
+ if cpx .tapped :
7
+ print ("Single tap detected!" )
Original file line number Diff line number Diff line change
1
+ from adafruit_circuitplayground .express import cpx
2
+
3
+ while True :
4
+ if cpx .button_a :
5
+ cpx .start_tone (262 )
6
+ elif cpx .button_b :
7
+ cpx .start_tone (294 )
8
+ else :
9
+ cpx .stop_tone ()
Original file line number Diff line number Diff line change
1
+ from adafruit_circuitplayground .express import cpx
2
+
3
+ while True :
4
+ if cpx .touch_A1 :
5
+ print ('Touched pad A1' )
6
+ if cpx .touch_A2 :
7
+ print ('Touched pad A2' )
8
+ if cpx .touch_A3 :
9
+ print ('Touched pad A3' )
10
+ if cpx .touch_A4 :
11
+ print ('Touched pad A4' )
12
+ if cpx .touch_A5 :
13
+ print ('Touched pad A5' )
14
+ if cpx .touch_A6 :
15
+ print ('Touched pad A6' )
16
+ if cpx .touch_A7 :
17
+ print ('Touched pad A7' )
You can’t perform that action at this time.
0 commit comments