Ambiet Light Using Arduino

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

NURFAZILA BINTI OTHMAN B20100034

Ambient Light System Using Arduino

About this project


The project is about how to learn to make a sensor in the dark place and see how bright the
LED Light is.
Components
 Arduino Uno
 Led Light (Required Red LED and Yellow LED)
 1 piece of 1k Ohm resistor (Color : Brown, Black. Red, Yellow)
 2 piece of 220 Ohm resistor (Color : Red, Red, Brown, Gold)
 Breadboard wire
 Breadboard
 Light sensing

Code
int light = 0; // store the current light value
void setup() {
// put your setup code here, to run once:
Serial.begin(9600); //configure serial to talk to computer
pinMode(13, OUTPUT); // configure digital pin 13 as an output
pinMode(12, OUTPUT); // configure digital pin 12 as an output
}
void loop() {
// put your main code here, to run repeatedly:
light = analogRead(A0); // read and save value from PR

Serial.println(light); // print current light value

if(light > 450) { // If it is bright...


Serial.println("It is quite light!");
digitalWrite(13,LOW); //turn left LED off
digitalWrite(12,LOW); // turn right LED off
NURFAZILA BINTI OTHMAN B20100034

}
else if(light > 229 && light < 451) { // If it is average light...
Serial.println("It is average light!");
digitalWrite(13, HIGH); // turn left LED on
digitalWrite(12,LOW); // turn right LED off
}
else { // If it's dark...
Serial.println("It is pretty dark!");
digitalWrite(13,HIGH); // Turn left LED on
digitalWrite(12,HIGH); // Turn right LED on
}
delay(1000); // don't spam the computer!
}

Before After

Ambient Light schematics


NURFAZILA BINTI OTHMAN B20100034

Video:
Url :
https://mustedumy-my.sharepoint.com/:v:/g/personal/nurfazila_othman_ug_must_edu_my/
EaTJWBGkQAhEi8mIvVITD5gBBI4_CJLPyUNm0gw-4C_T4w?email=asiah
%40must.edu.my&e=AIFnUm

You might also like