Arduino Light sensor LDR Monitor with a LCD Nokia 5110 Tutorial



Hardware Required

  • Arduino Uno

  • LDR (photo resistor) , Light Dependent Resistor
  • 10k ohm resistors  x 5
  • 1K ohm resistors x 2
  • Wires
  • Breadboard
  • LCD Nokia 5110 Display

Schematic diagram


Arduino with LDR sensor

Resistor 10K ohm



Arduino with Nokia 5110 




  • Connect the pin 1 (RST Pin) to the pin 12 of Arduino through the 10K resistor.
  • Connect the pin 2 (SCE Pin) to the pin 11 of Arduino through the 1K resistor.
  • Connect the pin 3 (D/C Pin) to the pin 10 of Arduino through the 10K resistor.
  • Connect the pin 4 (DIN Pin) to the pin 9 of Arduino through the 10K resistor.
  • Connect the pin 5 (CLK Pin) to the pin  8 of Arduino through the 10K resistor.
  • Connect the pin 6 (VCC Pin) to the 3.3V pin of Arduino.
  • Connect the pin 7 (LED Pin) to the pin 7 of Arduino through the 1K resistor
  • Connect the pin 8 (GND Pin) to the GND of Arduino.

Arduino Sketch

#include <LCD5110_Graph.h>
#include <MedianFilter.h>

MedianFilter test(10, 0);

LCD5110 myGLCD(8,9,10,12,11);

extern unsigned char SmallFont[];
extern unsigned char BigNumbers[];

void setup()
{
  myGLCD.InitLCD();
  myGLCD.setFont(SmallFont);

 // randomSeed(analogRead(0));

  pinMode(7, OUTPUT);
  digitalWrite(7,LOW);
}

void loop()
{
  String str;
  int val = analogRead(A0);

  val = map(val,300,950,0,100);

  test.in(val);
  val = test.out();
 
   str = String(val);
 
    myGLCD.setFont(SmallFont);
    myGLCD.print("LDR METER", 0, 0);
    myGLCD.drawLine(0,10,84,10);
    myGLCD.setFont(BigNumbers);
   
    myGLCD.print(str,7,18);

    myGLCD.setFont(SmallFont);
    myGLCD.print("%", 40, 30);
 
    myGLCD.update();
    delay(50);

}

ความคิดเห็น