-
Notifications
You must be signed in to change notification settings - Fork 66
Expand file tree
/
Copy pathknight_rider1.ino
More file actions
46 lines (36 loc) · 1.01 KB
/
knight_rider1.ino
File metadata and controls
46 lines (36 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <Automaton.h>
Atm_led led[6];
Atm_timer timer;
Atm_step step;
Atm_analog pot;
// Timer drives step sequencer in sweep mode, step sequencer blinks leds.
short event = Atm_led::EVT_BLINK;
static short pin_list[] = { 4, 5, 6, 7, 8, 9 };
int blink_time = 70;
int interval_time = 50;
void setup() {
// Initialize the step sequencer
step.begin()
.trigger( Atm_step::EVT_SWEEP );
// Add the timer
timer.begin( interval_time )
.onTimer( step, Atm_step::EVT_STEP )
.repeat( ATM_COUNTER_OFF );
// Add the leds and link them to the step sequencer
for ( short i = 0; i <= 5; i++ ) {
led[i].begin( pin_list[i] )
.blink( blink_time, 1, 1 );
step.onStep( i, led[i], event );
}
pot.begin( A0 )
.range( 10, 200 )
.onChange( [] ( int idx, int v, int up ) {
timer.interval( v );
});
// Move last led from step 5 to step 7 to make sweep work properly!
step.onStep( 5 ).onStep( 9, led[5], event );
timer.start();
}
void loop() {
automaton.run();
}