NokiaLCD

Received my LCD from NOKIA 5110(or 3110 – can’t remember really)
and started to play with it.
I’ve used Adafruit’s libraries (they are awesome…).
For download from there-> https://github.com/adafruit/Adafruit-PCD8544-Nokia-5110-LCD-library
local copy

though this one requires this one as well -> https://github.com/adafruit/Adafruit-GFX-Library
local copy

and below is effect of my HC-SR04 and this nifty LCD.

radar

image developed using Fritzing.


#include <Adafruit_GFX.h>
#include <Adafruit_PCD8544.h>

// pin 3 - Serial clock out (SCLK)    3
// pin 4 - Serial data out (DIN)      4
// pin 5 - Data/Command select (D/C)  5
// pin 7 - LCD chip select (CS)       7
// pin 6 - LCD reset (RST)            6
/*
HC-SR04 VCC -> ARDU 5V
HC-SR04 TRIG-> ARDU 31
HC-SR04 ECHO-> ARDU 33
HC-SR04 GND -> ARDU GND
*/

#include <Ultrasonic.h>
Ultrasonic ultrasonic(31,33);


Adafruit_PCD8544 display = Adafruit_PCD8544(3, 4, 5, 7, 6);

int i=0;
int dist,inv=0;
boolean stan=0;

void setup()   {
  display.begin();
  display.setContrast(40); 
  display.clearDisplay();
}

void loop() {
distance();  


//sweep loops
for(i=0;i<=84;i=i+2){
      if(i>0){
    display.clearDisplay();     
  display.drawLine(i-2,0,42,47,WHITE);  
  display.drawLine(i,0,42,47,BLACK);
  grid();
  distance();  
  } else {
   display.clearDisplay();  
  display.drawLine(i,0,42,47,BLACK);
  grid();
  distance();  
  }
  display.display();    
  delay(50);   
}
for(i=84;i>=0;i=i-2){
   if(i>=84){
      display.clearDisplay();
  display.drawLine(i,0,42,47,BLACK);
  grid();
  distance();  
  display.display();    
  delay(50);
  } else {
     display.clearDisplay();
  display.drawLine(i+2,0,42,47,WHITE);   
  display.drawLine(i,0,42,47,BLACK);
  grid();
  distance();  
  display.display();    
  delay(50);     
  }
}
distance();  
}

void distance(){
  grid();
  display.setCursor(66,33);
  dist=ultrasonic.Ranging(CM);
  display.println(dist);
  if (dist<=5){
  display.setCursor(54,41);
  display.println("ALERT");  
  }  
}
  
void grid(){
  //function body
  display.drawLine(0,0,42,47,BLACK);
  display.drawLine (84,0,42,47,BLACK);
  display.drawCircle(42,47,5,BLACK); 
  display.drawCircle(42,47,15,BLACK);
  display.drawCircle(42,47,25,BLACK);
  display.drawCircle(42,47,35,BLACK);
  display.drawCircle(42,47,45,BLACK);  
  display.drawCircle(42,47,55,BLACK);
  display.fillTriangle(0,1,41,47,0,47,WHITE);
  display.fillTriangle(84,1,43,47,84,47,WHITE);
  display.drawLine(0,7,0,47,BLACK);
  display.drawLine(42,0,42,47,BLACK);
  display.drawLine(0,47,3,47,BLACK);
  display.drawLine(0,42,1,42,BLACK);
  display.drawLine(0,37,3,37,BLACK);
  display.drawLine(0,32,1,32,BLACK);
  display.drawLine(0,27,3,27,BLACK);
  display.drawLine(0,22,1,22,BLACK);
  display.drawLine(0,17,3,17,BLACK);
  display.drawLine(0,12,1,12,BLACK);
  display.drawLine(0,7,3,7,BLACK);
  display.fillCircle(42,(48-dist),2,BLACK);
}

Leave a Reply