Exercise 12 - Auto Brightness
Exercise 12 - Auto Brightness
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
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);
delay(500);
}
Result:
Thus, the program detect light using LDR sensor and arduino was developed
successfully.
Ex. No.5c
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.