This digital input example uses a Button to switch the status of a LED every time it is pushed.
The circuit is the same as in the previous example.
Connect the Button and the led as shown in Figure 1:
Notes:
The longer LED PIN is the positive.
Button PINs can also be inverted.
Write a sketch K to define:
When the automa has 2 states use led as a status variable.
Button :: !D3
gnd :: d8
led :: d7
Click = Button==1
start = [gnd=0,led=0]
stop = [led=0]
!led & Click -> led=1 ##
led & Click -> led=0 ##
or simply load the sketch in the workspace with the command
] load e06_relay_effect
Initialize the system with the command:
] start
the LED is off.
Press and release the button
> Click
the LED turns on and the Click event is sent to the Internet
Press and release the button
> Click
the LED turns off and the Click event is sent to the Internet
In this lesson you learned or repeated: