I have decided to do a little project for my home. There is a two light domes in front gate pillars of my home, we used to switch on the light at evening time as it will get too dark, and we are too lazy to ask each other to do so on regular basis...well, my brain start to think about "How to make it automated". I did a quick code in Arduino...
A LDR to read the light source, a potentiometer to calibrate the trigger point to switch on the light, a set button for manual calibration, a smart button to auto calibration. I am going to use the raw ADC value of LDR and as well potentiometer value. While setting manual calibration, the potentiometer value will be the trigger point of light source, the set button stores the value of the potentiometer in variable for trigger point. the smart button is just store the current LDR value as trigger point, it's very useful to set the exact atmosphere light source reading.
This is the code...
int sensorValue, calibration, quickCalibration, triggerPoint, setButtonState = 0, smartButtonState = 0; void setup() { pinMode(8, OUTPUT); pinMode(7, INPUT); pinMode(4, INPUT); Serial.begin(9600); } void loop() { sensorValue = analogRead(A0); // ADC value from LDR calibration = analogRead(A1); // ADC value from potentiometer setButtonState = digitalRead(7); smartButtonState = digitalRead(4); if (setButtonState == HIGH) { triggerPoint = calibration; // Manual calibration } if (smartButtonState == HIGH) { triggerPoint = sensorValue+25; // Smart calibration } if (sensorValue < triggerPoint){ digitalWrite(8, HIGH); // Output to relay } else { digitalWrite(8, LOW); // Output to relay } Serial.println(sensorValue); Serial.println(calibration); delay(5); }
It's just on breadboard level I have to buy a relay to handle 220V switching and power supply for MCU My first thought was to use ATTiny13A but due to it's low memory of 1KB I have to go for ATmega8-16PU
I will continue to update this project when it's progress...
Top Comments