Communicating Arduino Using Serial Port Communication In this tutorial we'll see, how to program Arduino to send and receive signals using serial ports. We'll send signals from PC to our UNO board, which will change the state of the LED and will return the current state. Components Required - 1 * Arduino UNO - 1 * USB Cable - 1 * LED - 1 * 220Ω Resistor - 1 * Breadboard - Several jumpers wires Circuit Diagram Procedure 1. Make the connections according to the circuit diagram. 2. Connect your Arduino UNO to PC. 3. Upload the code provided to the board using Arduino IDE. 4. Now go to tools > Serial Monitor. Try entering 0 and 1 alternatively to play with the LED. Code int ledpin= 11 ; //definition digital 11 pins as pin to control the LED void setup () { Serial . begin ( 9600 ); // opens serial port, sets data rate to 9600 bps pinMode (ledpin,OUTPUT); //Set digital 11 port mode, the OUTPUT for the output } void loop () {
Controlling LED with a Push Button using Arduino In this tutorial we will learn how to detect the state of a button, and then toggle the state of the LED based on the state of the button. Components Required: - 1 * Arduino UNO - 1 * USB Cable - 1 * Button - 1 * LED - 1 * 10kΩ Resistor - 1 * 220Ω Resistor - 1 * Breadboard - Several jumpers wire Circuit Diagram: Procedure: 1. Make the connections according to the circuit diagram. 2. Connect your Arduino UNO to PC. 3. Upload the code provided to the board using Arduino IDE. 4. Enjoy playing with LED. Code: int ledpin=11; //definition digital 11 pins as pin to control the LED int btnpin=2; //Set the digital 2 to button interface volatile int state = LOW; // Defined output status LED Interface void setup() { pinMode(ledpin,OUTPUT); //Set digital 11 port mode, the OUTPUT for the output