0% found this document useful (0 votes)
26 views2 pages

Session 4 Exercise 2: Objective: Building A Control Node. Steps

This document provides steps to build a control node using an Arduino board that can turn an LED on or off by sending commands from a computer. The steps include plugging the Arduino into the computer, connecting an LED with resistor to pin 11, uploading code to control the LED with serial commands, and using the serial monitor to send 'c' or 'C' to turn the LED on and 'd' or 'D' to turn it off.

Uploaded by

lingesh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views2 pages

Session 4 Exercise 2: Objective: Building A Control Node. Steps

This document provides steps to build a control node using an Arduino board that can turn an LED on or off by sending commands from a computer. The steps include plugging the Arduino into the computer, connecting an LED with resistor to pin 11, uploading code to control the LED with serial commands, and using the serial monitor to send 'c' or 'C' to turn the LED on and 'd' or 'D' to turn it off.

Uploaded by

lingesh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Session 4 Exercise 2:

Objective: Building a control node.

Steps:

 Plug Arduino board to into your computers USB port.


 Connect external LED in series with a 1 Kohm resistor to pin 11 as shown in below
picture.

 Upload below given program on Arduino board.


 Open serial monitor and send letter c or C and d or D to switch LED ON and OFF
respectively.
 An acknowledgement message will be displayed on serial monitor.

Code:

const int ledpin= 11;

void setup()

Serial.begin(9600); //Communicate with PC/LAPTOP

pinMode(ledpin, OUTPUT);

digitalWrite(ledpin,LOW);

}
void loop()

if(Serial.available()>0)

int val = Serial.read();

if(val=='c'|| val== 'C')

digitalWrite(ledpin,HIGH);

Serial.println("LED is ON");

if(val=='d' || val == 'D')

digitalWrite(ledpin,LOW);

Serial.println("LED is OFF");

You might also like