File tree Expand file tree Collapse file tree 3 files changed +46
-5
lines changed Expand file tree Collapse file tree 3 files changed +46
-5
lines changed Original file line number Diff line number Diff line change 31
31
import array
32
32
33
33
34
- def square_wave (sample_length = 2 ):
34
+ def square_wave (sample_length = 2 ):
35
35
"""Generate a single square wave of sample_length size"""
36
- s = array .array ("H" , [0 ] * sample_length )
37
- for i in range (sample_length / 2 ):
38
- s [i ] = 0xFFFF
39
- return s
36
+ square = array .array ("H" , [0 ] * sample_length )
37
+ for i in range (sample_length // 2 ):
38
+ square [i ] = 0xFFFF
39
+ return square
Original file line number Diff line number Diff line change
1
+ """
2
+ 'sine_demo.py'.
3
+
4
+ =================================================
5
+ toggles the builtin LED using a sine wave
6
+ """
7
+ import time
8
+ import board
9
+ import digitalio
10
+ from adafruit_waveform import sine
11
+
12
+ LED = digitalio .DigitalInOut (board .D13 )
13
+ LED .switch_to_output ()
14
+
15
+ SINE_SAMPLE = sine .sine_wave (150 , 50 )
16
+
17
+ while True :
18
+ for i in range (len (SINE_SAMPLE )):
19
+ LED .value = i
20
+ print (LED .value )
21
+ time .sleep (0.50 )
Original file line number Diff line number Diff line change
1
+ """
2
+ 'square_demo.py'.
3
+
4
+ =================================================
5
+ toggles the builtin LED using a square wave
6
+ """
7
+ import time
8
+ import digitalio
9
+ import board
10
+ from adafruit_waveform import square
11
+
12
+ LED = digitalio .DigitalInOut (board .D13 )
13
+ LED .switch_to_output ()
14
+ SAMPLE_SQUARE = square .square_wave (2 )
15
+
16
+ while True :
17
+ for i in range (len (SAMPLE_SQUARE )):
18
+ LED .value = i
19
+ print (LED .value )
20
+ time .sleep (0.5 )
You can’t perform that action at this time.
0 commit comments