Arduino Photoresistor Tutorial with a Nokia 5110 display

Arduino Photoresistor Tutorial with a Nokia 5110 display

Dear friends in this video we build a simple light meter. This is a very simple circuit with which we can measure the light intensity falling on a sensor. We are using a photoresistor this one here, an Arduino for controlling the whole circuit and a display a Nokia 5110 display. In the display we can see the light intensity measurement in percent and a bar graph. A live bar graph. So, if I put my finger on the sensor you can see that the light intensity falls. It is a very simple circuit, don’t be fooled by the wires. We only need a photoresistor and a resistor. An Arduino and a display in order to display the results. So it is a very easy circuit and very useful in order to detect darkness or presence of light. We can power down our equipment when is night or power it up when it is day. So let’s see how easy it is to connect it to an Arduino. All we need is a photoresistor and a standard resistor. The photoresistors are light controlled variable resistors. These are also know as Light Dependent Resistors LDRs. In terms of operation a photoresistor is usually very resistive, in MΩ, when placed in the dark however when it is illuminated it’s resistance decreases significantly. We’re going
to use this photoresistor and a standard resistor about 100KΩ. Any resistor from 10ΚΩ to 100 ΚΩ is fine. Then we take the breadboard and connect the photoresistor and the resistor here. First I put in the photoresistor and then the resistor. Ok this is the 100 ΚΩ resistor. Now, let’s put a red wire here and connect it to the positive and a black wire from here and connect it to the negative. Now, we are ready the signal we are going to receive from the photoresistor is this pin here. We place a green wire and this goes to an analog pin on our Arduino. So, let’s connect the Arduino as well. Arduino Mega is here. We take a red wire from 5V and we connect it to 5v of the breadboard We take ground from Arduino and we connect it to Ground of the breadboard and signal to an analog pin of our choice. I have chosen pin 13. This is a simple circuit which reads the value from a photoresistor. Now we have to connect the display in order to display the results. I’m not going to show you
how to connect the Nokia 5110 display now because it takes some time but you can watch our previous video in which we describe the connection of the display with the Arduino in detail. OK I now have connected the display as well. Let’s power it up and see if it is working. okay we are ready, as you can see it’s very easy, the light meter is working fine. Now lets see the software side on this project. So
let’s look at the code of this project first of all we have to include the Nokia 5110 Graph.h library that we discussed in the previous video.
Please check this video in order to see how to use this library in order to drive the 5110 display. So first of all we declare the LCD, the pins of the LCD, some variables here and the most important variable is the LDR pin 13, we declare in which pin the photoresistor is connected. We have connected it to pin 13 so this is it. Then the Setup function we initialize the LCD screen and set the font.Next in the loop function which is iterated for ever, with about 100ms delay, first of all we clear the screen and update the screen and we read the light intensity. The light intensity is an int variable and it has a avalue around from 0 to 1,023. I have calibrated the sensor I saw that when the photoresistors is placed under direct sunlight the value that it reads is about 20. And when it is absolute darkness it is around 1010. So, what I have done, is that I don’t want these values that don’t mean anything I
converted them to percent so when we have absolute
darkness I map it to 0%. And when I have full sunlight the the photoresistor will read a value of around 20 I map it to a value of 100% In this line we make the convertion. From analogRead to percent. The I add the percent sign here and convert these string to a character array because the lcd.print command can only display caracher arrays. not strings not integers not floats. I take the light intensity from here I convert it to percent, then I convert it to a character array, and I print it on the screen. Then we have the printBar and fillBar functions. Those are the functions that are responsible for drawing the bar graph in the display. It is very simple, the first one draws an empty rectangle and then the fillBar it converts the percent value into pixels and draws four lines in order to fill the bar graph. That’t the code, it’s to use and understand, so If you want download it from the link that you can find in the link in the description of the video. So that’s our simple light meter, as you can see It is very to intergrate in your project, it is very low cost A photoresistor cost around 2$ for 50 units It is very very cheap and of course you also need a very cheap resistor. The display has also very low cost its about 2$ and of course you need an Arduino. As we said before with a very low cost, around 0.05$ you can add light detection capability in your project. Thank you very much for watching the video. Please subscribe to our channel if you want to watch our next videos and projects and press like if you liked the video. thank you very much for watching our
video please subscribe to our time if you want to watch our next to be
there was and projects and press like if you liked this video thank you!

15 thoughts on “Arduino Photoresistor Tutorial with a Nokia 5110 display

  1. Don't you need to be careful about the logical levels of the Nokia 5110 display?
    I've read that it must be 3.3V, and the Arduino sends out 5V logic.

  2. Beginner question, why do you need a resistor in series after the photoresistor? How would the circuit behave without it? Thanks

  3. Hello, Great video and instruction, but where can I get the graphic file (graphis.c) ?

  4. Does this light meter can show the measurement in Lux or Lumen etc?

  5. Thank you for this LDR circuit
    I have strange problem,
    (1) I put Lm35 to A0 to measure temperature and display on LCD16x02 ->OK
    (2) Then I connect this circuit to A1 and display to LCD LDR ->OK
    (3) BUT now with (2) connected (1) LM35 does not work temperature measure unstable, If I disconnect A1 wire (1) is OK again.
    Connection to of LDR cicruit to A1 effects A0 stability?
    I try different pins delays Nothing ?!?

  6. stupid nolifers, go have some fun outside

  7. can percentage converted to lumens …it shows lumens or lex reply please

  8. how kOm res you put?

  9. Excelente con sub titulos.

  10. Great idea using the Nokia display!

  11. Hello, can I know how to have the lux meter give data in lux rather than the percentage?

  12. Fun fact: any LED will produce a (tiny) current when exposed to light, like a poor man's solar panel. It can be enough to detect day/night if you don't have an LDR at hand.

  13. My display inverted the bar … When the LDR is in darkness .. the Bar shows 100% …. check the sketch but seems o.k …..

  14. tq, i m very like ur projects

  15. Hi Nick. Thanks for the great job you're doing. I had an issue with your code but

    I finally found the problem; your code works better if you connect the circuit to analog pin0 instead digital pin13.
    Just change int LDRpin = 13; to int LDRpin = A0; and change the data connection wire.
    Hope it will be usefull !

    Thanks again from Spain.

Leave a Reply

Your email address will not be published. Required fields are marked *