Embedded Programming

The task was to build a program that works with human input. For that I used a button which I connected to my board. As output I used two of the LEDs that also were on the board. In the begging I defined the names and two boolean variables.

I used the setup to declare the pinmodes to output and input, and also had to set the default value of the button to ground. For the Serial communication I set the baud to 9600 and print program started.

In the loop I used and if conditon to check wether the button is pressed. And when its pressed it writes that in the serical monitor and changes the state of the booleans I use. When you press more often you switch through the states.

After I got the booleans sorted out I just had to switch the states of the LEDs and then wait a quarter of a second before the button can be pressed again.

Here is what the serial monitor printed out after pressing the button four times

And this is the board with the button in action.