Introduction: Automatic Reading Lamp (Arduino)
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.
Step 1: 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.
Step 2: The Code
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); }
Step 3: You're Done!
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!