In this recipe, we will be attaching an LED to the Arduino board and will prompt the user to press either 0 or 1. The user can input a value using the serial port. If the value entered by the user is 0, it will switch off the LED and if the value entered by the user is 1, it will make the LED glow.
Taking input from the serial port using Arduino
How to do it…
To take input from the serial port using Arduino, perform the following steps:
- Invoke the Arduino IDE. Arduino opens up with a file showing its default content, as follows:
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}
- Connect the Arduino board to your PC.
- From the Tools menu, select Port...