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

CS3691 Arduino Lab Full Details

The document outlines four Arduino programs for an Embedded System and IoT Lab. The programs include LED blinking, button-controlled LED, LDR sensor with LED, and temperature measurement using an LM35 sensor. Each program includes the aim, code, and expected output for the respective tasks.

Uploaded by

lakshmimd2005
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)
5 views2 pages

CS3691 Arduino Lab Full Details

The document outlines four Arduino programs for an Embedded System and IoT Lab. The programs include LED blinking, button-controlled LED, LDR sensor with LED, and temperature measurement using an LM35 sensor. Each program includes the aim, code, and expected output for the respective tasks.

Uploaded by

lakshmimd2005
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

CS3691 - Embedded System and IoT Lab - Arduino Programs

1. LED Blinking

Aim:
To blink an LED connected to digital pin 13 of Arduino UNO.
Program:
void setup() {
pinMode(13, OUTPUT);
}
void loop() {
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, LOW);
delay(1000);
}

Output:
The LED connected to pin 13 will blink ON for 1 second and OFF for 1 second repeatedly.

2. Button Controlled LED

Aim:
To control an LED using a push button connected to pin 2 of Arduino UNO.
Program:
void setup() {
pinMode(2, INPUT);
pinMode(13, OUTPUT);
}
void loop() {
int state = digitalRead(2);
if(state == HIGH) {
digitalWrite(13, HIGH);
} else {
digitalWrite(13, LOW);
}
}

Output:
When the button is pressed, the LED turns ON. When the button is released, the LED turns OFF.

3. LDR Sensor with LED

Aim:
To turn ON/OFF an LED based on ambient light using an LDR sensor.
Program:
int ldrPin = A0;
int ledPin = 13;
CS3691 - Embedded System and IoT Lab - Arduino Programs

void setup() {
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
int ldrValue = analogRead(ldrPin);
Serial.println(ldrValue);
if(ldrValue < 300) {
digitalWrite(ledPin, HIGH);
} else {
digitalWrite(ledPin, LOW);
}
delay(500);
}

Output:
In dark light conditions, the LED turns ON. In bright conditions, the LED turns OFF. The LDR value is shown in the Serial
Monitor.

4. Temperature Sensor (LM35)

Aim:
To measure and display the temperature using LM35 temperature sensor.
Program:
int sensorPin = A0;
void setup() {
Serial.begin(9600);
}
void loop() {
int reading = analogRead(sensorPin);
float voltage = reading * 5.0 / 1024.0;
float temperatureC = voltage * 100;
Serial.print("Temperature: ");
Serial.print(temperatureC);
Serial.println(" °C");
delay(1000);
}

Output:
The Serial Monitor displays the temperature in degrees Celsius updated every second.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy