Code for simple scheduled waves example

From Bcontrol

The code below focuses on what you need in order to make the state machine diagram of the figure. For complete standalone example code, including commands to initialize, start running the state machine, etc, go here

sma = StateMachineAssembler;

sma = add_scheduled_wave(sma, 'name', 'my_wave', 'preamble', 2);

sma = add_state(sma, 'name', 'STATE_0', 'self_timer', 0.0001, ...
   'input_to_statechange', {'Tup', 'my_start'});

sma = add_state(sma, 'name', 'MY_START', ...
   'input_to_statechange', {'Cin', 'start_wave'});

sma = add_state(sma, 'name', 'START_WAVE', 'self_timer', 0.0001, ...
   'input_to_statechange', {'Tup', 'light_on' ; 'Cout', 'light_off'}, ...
   'output_actions', {'SchedWaveTrig', 'my_wave'});

sma = add_state(sma, 'name', 'LIGHT_ON', ...
   'output_actions', {'DOut', center1led}, ...
   'input_to_statechange', {'Cout', 'light_off'; 'my_wave_In', 'side_lights'});

sma = add_state(sma, 'name', 'LIGHT_OFF', ...
   'input_to_statechange', {'Cin', 'light_on' ; 'my_wave_In', 'side_lights'});

sma = add_state(sma, 'name', 'SIDE_LIGHTS', ...
   'output_actions', {'DOut', left1led + right1led});

Simple scheduled waves.jpg