0% found this document useful (0 votes)
19 views4 pages

Exercise 5-Arduino Programming

The document outlines three exercises involving Arduino programming: making an LED blink, reading a light sensor, and reading a temperature sensor. Each exercise includes an aim, algorithm, program code, and a result confirming successful development. The programs demonstrate basic input/output operations using Arduino for LED control, light detection, and temperature measurement.

Uploaded by

gcetly.2
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)
19 views4 pages

Exercise 5-Arduino Programming

The document outlines three exercises involving Arduino programming: making an LED blink, reading a light sensor, and reading a temperature sensor. Each exercise includes an aim, algorithm, program code, and a result confirming successful development. The programs demonstrate basic input/output operations using Arduino for LED control, light detection, and temperature measurement.

Uploaded by

gcetly.2
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/ 4

Ex. No.

5a
LED BLINK
Date:

Aim:
To develop a program to make the LED blink using Arduino.

Algorithm:
Step1: start
Step2: Initialize the LED_PIN
Step3: Turn on the LED x wait for a second
Step 4: Turn off LED x wait for a second
Step 5: Stop

Program:
const int ledPin=13;
void setup()
{
pinMode(ledPin, OUTPUT);
}
void loop()
{
digitalWrite(ledPin, HIGH);
delay(1000);
digitalWrite(ledPin, LOW);
delay(1000);
}

Result:
Thus, the program to make the LED blink using arduino was developed
successfully.
Ex. No.5b

READING A LIGHT SENSOR


Date:

Aim:
To develop a program to detect light using light sensor and Arduino.

Algorithm:
Step 1: Start.
Step 2: Initialize the digital pin.
Step 3: Read the analog value to the sensor.
Step 4: Display the amount of brightness based on the analog value.
Step 5: Stop.
Program:
void setup()
{
Serial.begin(9600);
}
void loop()
{
int analogValue = analogRead(A0);

Serial.print("Analog reading = ");


Serial.print(analogValue);

if (analogValue < 100)


{
Serial.println(" - Very bright");
}
else if (analogValue < 200)
{
Serial.println(" - Bright");
}
else if (analogValue < 500)
{
Serial.println(" - Light");
}
else if (analogValue < 800)
{
Serial.println(" - Dim");
}
Else
{
Serial.println(" - Dark");
}

delay(500);
}
Result:
Thus, the program detect light using LDR sensor and arduino was developed
successfully.
Ex. No.5c

READING A TEMPERATURE SENSOR


Date:

Aim:
To develop a program to detect temperature using temperature sensor and
Arduino.
Algorithm:
Step 1: Start.
Step 2: Initialize the digital pin.
Step 3: Read the analog value to the sensor.
Step 4: Read the temperature.
Step 5: Display the temperature using serial monitor.
Step 6: Stop.

Program:
int val;
int tempPin=2;
void setup()
{
Serial.begin(9600);
}
void loop()
{
val = analogRead (tempPin);
float mv = (val/1024.0) *5000;
float cel = mv/10;
Serial.print("TEMPRATURE = ");
Serial.print(cel);
Serial.print("*C");
Serial.println();
delay(1000);
}

Result:
Thus, the program to detect temperature using temperature sensor and arduino
was developed successfully.

You might also like