02_Switch_input01 by yasusanto

This sketch is missing a short description
This program outputs only to [Serial Monitor](https://www.arduino.cc/en/Guide/Environment#serialmonitor) of Arduino. There is no other output (i.e. LEDs are not used). To open Serial Monitor, you need to click the magnifying glass icon at the top-right of Arduino application. ![enter image description here](https://www.arduino.cc/en/uploads/Guide/serial_monitor.png "enter image title here") (Serial Monitor Button) **pbPin1** and **pbPin2** are constants. A constant is a name used to refer to a fixed number. They are used here to define Arduino port numbers. Constants, as well as variables, can be any alpha-numerical text and can represent any number or string of text as long as same names are not used to refer to different constants or variables in your program. Constants are used here so that your program can be updated easily if you decide to change the port number of any component. **switch1** and **switch2** are variables to store changing values (state of each switch is stored for this program). A variable must be defined before it is used to store values. (see Variables in Arduino reference page) In **setup**, **swPin1** and **swPin2** (port 4 & 5) are set to **Input** because they need to read (rather than write) signals from switches. In the **loop()** (main) routine, the states (1 or 0) of switches are stored in **switch1** & **switch2** respectively by reading **swPin1** (port 4) and **swPin2** (port 5) The program is then paused for 100 milliseconds to prevent Arduino from reading the state of switch signals too frequently. Serial commands send states (1 or 0) of both switches separated by a "," to Arduino's serial monitor that runs on your computer. The program will then go back to the beginning of the **loop()** routine. ![enter image description here](http://coadaptable.com/dnb603/DNH603_LEDs+Switches.png "enter image title here")

Embed This Sketch

Use the following HTML code to embed the sketch code above in your blog or website.

<iframe style="height: 510px; width: 100%; margin: 10px 0 10px;" allowTransparency="true" src="https://codebender.cc/embed/sketch:106851" frameborder="0"></iframe>

Embed The Serial Monitor

You can also embed the Serial Monitor section! Just use this HTML code.

<iframe style="height: 510px; width: 100%; margin: 10px 0 10px;" allowTransparency="true" src="https://codebender.cc/embed/serialmonitor" frameborder="0"></iframe>