These projects are good for the beginners to learn basic things. We are showing a basic light meter, you’ll try to add a push button to start and another push button to stop. In previous articles we have shown how to create basic sound meter with microphone and Arduino. That circuit was slightly difficult. LDR aka Photoresistors are more easy electronic component. Indeed, you can directly use a LDR/Photoresistor with an LED without any microcontroller or IC. Obviously, we can build Arduino LDR/Photoresistor and LED based light meter too. Instead of multiple LED, we can use LED bar display which is nothing but just some LED inside a modular kit. We have borrowed the project from one Fritzing project. Basic usage of LDR with Arduino shown on official website, which is great to get started :
1 | https://www.arduino.cc/en/Tutorial/Calibration |
Arduino LDR/Photoresistor and LED Based Light Meter
Very less number of components needed for this project :
- Arduino board
- Breadboard
- Jumper wires
- 5 x LED
- 5 x 220 Ohm resistors
- 1 x 10K Ohm resistor
- LDR
This is the circuit diagram of this project :
---
Here is the code :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | const int in = A0; int inRead = 0; const int metOne = 2; const int metTwo = 3; const int metThree = 4; const int metFour = 5; const int metFive = 6; void setup(){ Serial.begin(9600); pinMode(metOne, OUTPUT); pinMode(metTwo, OUTPUT); pinMode(metThree, OUTPUT); pinMode(metFour, OUTPUT); pinMode(metFive, OUTPUT); } void loop(){ inRead = analogRead(A0); Serial.println(inRead); delay(40); digitalWrite(metOne, LOW); digitalWrite(metTwo, LOW); digitalWrite(metThree, LOW); digitalWrite(metFour, LOW); digitalWrite(metFive, LOW); if (inRead <= 100 && inRead > 30){ digitalWrite(metOne, HIGH); }else{ digitalWrite(metOne, LOW); if (inRead <= 200 && inRead > 100){ digitalWrite(metTwo, HIGH); digitalWrite(metOne, HIGH); }else{ digitalWrite(metOne, LOW); digitalWrite(metTwo, LOW); if (inRead <= 300 && inRead > 200){ digitalWrite(metTwo, HIGH); digitalWrite(metOne, HIGH); digitalWrite(metThree, HIGH); }else{ digitalWrite(metOne, LOW); digitalWrite(metTwo, LOW); digitalWrite(metThree, LOW); if (inRead <= 400 && inRead > 300){ digitalWrite(metTwo, HIGH); digitalWrite(metOne, HIGH); digitalWrite(metThree, HIGH); digitalWrite(metFour, HIGH); }else{ digitalWrite(metOne, LOW); digitalWrite(metTwo, LOW); digitalWrite(metThree, LOW); digitalWrite(metFour, LOW); if (inRead <= 1000 && inRead > 400){ digitalWrite(metTwo, HIGH); digitalWrite(metOne, HIGH); digitalWrite(metThree, HIGH); digitalWrite(metFour, HIGH); digitalWrite(metFive, HIGH); }else{ digitalWrite(metOne, LOW); digitalWrite(metTwo, LOW); digitalWrite(metThree, LOW); digitalWrite(metFour, LOW); digitalWrite(metFive, LOW); } } } } } } |