Wednesday, March 30, 2022

Dual 80x160 RGB LCD Robot eyes

My latest creation uses dual 80x160 RGB LCD's to produce two robot eyes.  They are wired together so they can not "wink".  On the other hand it only takes half of the code.  They are powered by an Arduino UNO.  I was going to do this with OLED's but someone sent me a LCD instead so I went with the LCD's.  Theoretically you can wire them to have different "CS" or chip selects so each eye would be independent.  I added some more circles.  There is a small white circle on the far left and right as well as a black circle that produces the ring around the blue of the eyes.

By the way these LCD's are five volt friendly and easily run off five volts as well as use five volt logic levels.

Here are a couple of pictures.  They are more blue in reality but the camera has issues with the blue.



Here is a video of them on YouTube.


Ideally you could have two channels of your 32 channel servo controller go to analog inputs of an Arduino to set the size and direction of the eyes.

Here is the code:
// Sample program for eyes on 80x160 TFT LCD Screen
// March 2022 by Bob Davis

#include <TFT.h>  // Arduino LCD library
#include <SPI.h>
 
// Pins
#define cs   10
#define dc   8
#define rst  9
// For Arduino Uno: MOSI = pin 11 and SCLK = pin 13.  
// Create an instance of the library
TFT TFTscreen = TFT(cs, dc, rst);

int width=160; 
void setup() {
 
   // Initialize the screen
   TFTscreen.begin();
   // Clear the screen
   TFTscreen.background(255,255,255);
   // Set font color to white
   TFTscreen.stroke(255,255,255);
   // Set the font size
   TFTscreen.setTextSize(2);
   // Write some text on the screen
//   TFTscreen.text("Hello World!",0,0);
}
 
void loop() {
   TFTscreen.background(255,255,255); // Clear Screen

   // Eyes Center  NOTE SCREEN IS UPSIDE DOWN 0,0=bottom right
   TFTscreen.fillCircle(25,65,15,0x0000);
   TFTscreen.fillCircle(135,65,15,0x0000); 
   TFTscreen.fillCircle(45,65,30,0x0000);
   TFTscreen.fillCircle(115,65,30,0x0000); 
   TFTscreen.fillRect(45,35,70,61,0x0000); // Connect Circles
   TFTscreen.fillCircle(80,65,35,0xFFFF);
   TFTscreen.fillCircle(80,65,30,0xFFE0);
   TFTscreen.fillCircle(80,65,10,0xFFFF);
   delay(1000);

   // Eyes Narrow
   TFTscreen.fill(255,255,255);
   TFTscreen.rect(0,30,160,20);
   TFTscreen.rect(0,78,160,21);
   delay(1000);

   // Eyes Right
//   TFTscreen.background(255,255,255);
   TFTscreen.fillCircle(25,65,15,0x0000);
   TFTscreen.fillCircle(135,65,15,0x0000); 
   TFTscreen.fillCircle(45,65,30,0x0000);
   TFTscreen.fillCircle(115,65,30,0x0000); 
   TFTscreen.fillRect(45,35,70,61,0x0000);// Connect Circles
   TFTscreen.fillCircle(110,65,35,0xFFFF);
   TFTscreen.fillCircle(110,65,30,0xFFE0);
   TFTscreen.fillCircle(110,65,10,0xFFFF);
   delay(1000);
   
   // Eyes Left
//   TFTscreen.background(255,255,255);
   TFTscreen.fillCircle(25,65,15,0x0000);
   TFTscreen.fillCircle(135,65,15,0x0000); 
   TFTscreen.fillCircle(45,65,30,0x0000);
   TFTscreen.fillCircle(115,65,30,0x0000); 
   TFTscreen.fillRect(45,35,70,61,0x0000);// Connect Circles
   TFTscreen.fillCircle(50,65,35,0xFFFF);
   TFTscreen.fillCircle(50,65,30,0xFFE0); // Blue
   TFTscreen.fillCircle(50,65,10,0xFFFF);
   delay(1000);
    
   // Eyes Big
   TFTscreen.fillCircle(25,65,15,0x0000);
   TFTscreen.fillCircle(135,65,15,0x0000); 
   TFTscreen.fillCircle(45,65,30,0x0000);
   TFTscreen.fillCircle(115,65,30,0x0000); 
   TFTscreen.fillCircle(60,65,40,0x0000);
   TFTscreen.fillCircle(100,65,40,0x0000); 
   TFTscreen.fillRect(65,25,40,81,0x0000); // Connect Circles
   TFTscreen.fillCircle(80,65,35,0xFFFF);
   TFTscreen.fillCircle(80,65,30,0xFFE0);
   TFTscreen.fillCircle(80,65,10,0xFFFF);
   delay(2000);
}

No comments:

Post a Comment