Automatic Reading Lamp (Arduino)
by Rainimator in Circuits > Arduino
338 Views, 0 Favorites, 0 Comments
Automatic Reading Lamp (Arduino)
.png)
.png)
.png)
Hi. this is an automatic reading lamp. set this up on a lamp/light and then when you sit down in that seat, it detects your heat and turns on. and i will be entering 8th grade in the fall.
The Base

you will start with an Arduino and a breadboard. connect the wires as shown. now add the light bulb and temperature detector. it's not done yet. the next step is the code.
The Code
.png)
.png)
this wont do anything if it doesn't have any code. so go into code, and click, "text". then copy and paste this code
int baselineTemp = 0;
int celsius = 0; int fahrenheit = 0;
void setup() { pinMode(A0, INPUT); Serial.begin(9600);
pinMode(2, OUTPUT); pinMode(3, OUTPUT); pinMode(4, OUTPUT); }
void loop() { baselineTemp = 40; celsius = map(((analogRead(A0) - 20) * 3.04), 0, 1023, -40, 125); fahrenheit = ((celsius * 9) / 5 + 32); Serial.print(celsius); Serial.print(" C, "); Serial.print(fahrenheit); Serial.println(" F"); if (celsius < baselineTemp) { digitalWrite(2, LOW); digitalWrite(3, LOW); digitalWrite(4, LOW); } if (celsius >= baselineTemp && celsius < baselineTemp + 10) { digitalWrite(2, HIGH); digitalWrite(3, LOW); digitalWrite(4, LOW); } if (celsius >= baselineTemp + 10 && celsius < baselineTemp + 20) { digitalWrite(2, HIGH); digitalWrite(3, HIGH); digitalWrite(4, LOW); } if (celsius >= baselineTemp + 20 && celsius < baselineTemp + 30) { digitalWrite(2, HIGH); digitalWrite(3, HIGH); digitalWrite(4, HIGH); } if (celsius >= baselineTemp + 30) { digitalWrite(2, HIGH); digitalWrite(3, HIGH); digitalWrite(4, HIGH); } delay(1000); }
You're Done!
.png)
.png)
To test it, click, "Start Simulation". then click the temperature detector and whenever there is a big heat source, the light will turn on. now just get a lamp and set it up so the temperature detector is pointing towards you. now when you sit down, the lamp detects your heat and turns on. Enjoy!