Monday, March 21, 2022

Nokia 5110 Robot Face Eyes and Mouth

 I thought I would try using a Nokia LCD for creating a face for my robot.  However I was greatly disappointed.  If you make his eyes white, then the border is also white.  So I had to make his eyes black.  The effect is not nearly as pronounced.  As a result I only created two expressions for this LCD.

Here is the two faces:



Here is the code for those two faces.

/*********************************************************************
Nokia 5110 LCD Robot Face
Many thankls to AdaFruit!
*********************************************************************/
#include <Adafruit_GFX.h>
#include <Adafruit_PCD8544.h>
// Software SPI (slower updates, more flexible pin options):
// pin 7 21- Serial clock out (SCLK)
// pin 6 20- Serial data out (DIN)
// pin 5 19- Data/Command select (D/C)
// pin 4 18- LCD chip select (CS)
// pin 3 17- LCD reset (RST)
//Adafruit_PCD8544 display = Adafruit_PCD8544(21, 20, 19, 18, 17);
Adafruit_PCD8544 display = Adafruit_PCD8544(7, 6, 5, 4, 3);
void setup()   {
  display.begin();
  display.setContrast(60);  // Default is 50
  display.clearDisplay();   // clears the screen and buffer
}
void loop() {
  // draw big eyes and mouth
  display.fillCircle(display.width()/6, display.height()/5, 10, BLACK);
  display.fillCircle(display.width()/6*5, display.height()/5, 10, BLACK);
  display.fillCircle(display.width()/4, display.height()-10, 10, BLACK);
  display.fillCircle(display.width()/4*3, display.height()-10, 10, BLACK);
  display.fillRect(display.width()/4, display.height()-20,display.width()/4*2,20, BLACK);
  display.display();
  delay(2000);
  display.clearDisplay();
  // draw eyes and mouth
  display.fillCircle(display.width()/6, display.height()/5, 7, BLACK);
  display.fillCircle(display.width()/6*5, display.height()/5, 7, BLACK);
  display.fillCircle(display.width()/4, display.height()-10, 5, BLACK);
  display.fillCircle(display.width()/4*3, display.height()-10, 5, BLACK);
  display.fillRect(display.width()/4, display.height()-14,display.width()/4*2,10,BLACK);
  display.display();
  delay(2000);
  display.clearDisplay();
}

No comments: