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);
}

Wednesday, March 23, 2022

Improved Arduino Robot Face on Parallel TFT LCD

Improved the Arduino Robot Face by putting it on a 2.4 inch Parallel LCD. The LCD is a HY-TFT240 to be exact. This larger 320 by 240 LCD gives more room for adding a mouth as well as bigger eyes. However the LCD requires 8 data bits, 4 control lines power and ground. So there are more wires required. You can even get this type of LCD in a shield that plugs right into the Arduino. That arrangement will not fit in the robots head.

Here are two of the many possible faces.



This is what the setup looks like when it is not installed in the robot.


This is the video of the robot faces.


This is the code. I do not have an interface to select what face to display yet.

// Parallel LCD to Robot Face
// By Bob Davis
// Adafruit_TFTLCD LIBRARY MUST BE CONFIGURED.
// SEE RELEVANT COMMENTS IN Adafruit_TFTLCD.h.
// Some code by Open-Smart Team and Catalex Team
//
// Board: Arduino UNO R3 or Arduino Mega2560

// ADAFRUIT DRIVERS
#include <Adafruit_GFX.h>    // Core graphics library
#include <Adafruit_TFTLCD.h> // Hardware-specific library
#define LCD_CS A3 // Chip Select goes to Analog 3
#define LCD_CD A2 // Command/Data goes to Analog 2
#define LCD_WR A1 // LCD Write goes to Analog 1
#define LCD_RD A0 // LCD Read goes to Analog 0
#define LCD_RESET A4 // Actually use Arduino's reset pin
Adafruit_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);

//*********************************************//
// Pin assignments for the LCD *ADAFRUIT*
// GND           -- GND
// 3V3           -- 3.3V
// CS            -- A3  
// RS            -- A2
// WR            -- A1
// RD            -- A0
// RST           -- RESET or resistor to +V
// LED           -- GND
// DB0-DB7       -- 8, 9, 2, 3, 4, 5, 6, 7

int width=320;  // scales 
int height=240;
// uint16_t g_identifier;
// Assign names to color values:
#define BLACK   0x0000
#define BLUE    0x001F
#define RED     0xF800
#define GREEN   0x07E0
#define CYAN    0x07FF
#define MAGENTA 0xF81F
#define YELLOW  0xFFE0
#define WHITE   0xFFFF

void setup(void) {
  uint16_t identifier = 0x9325; // or 9341
//  tft.reset();
  tft.begin(identifier);
  tft.setRotation(1);
//  tft.setCursor(0, 0);
  tft.fillRect(0, 0, width, height, BLACK);
}

void loop(void) {
   tft.fillRect(0, 0, width, height, BLACK);
   // Eyes Center
   tft.fillCircle(width*.1,height*.2,20,WHITE);
   tft.fillCircle(width*.1+40,height*.2,20,WHITE); // oblong fillCircle
   tft.fillRect  (width*.1,height*.2-20,40,41,WHITE);
   tft.fillCircle(width*.1+20,height*.2,20, BLUE);
   tft.fillCircle(width*.1+20,height*.2,10, BLACK);
   tft.fillCircle(width*.8,height*.2,20,WHITE);
   tft.fillCircle(width*.8+40,height*.2,20,WHITE); // oblong fillCircle
   tft.fillRect  (width*.8,height*.2-20,40,41,WHITE);
   tft.fillCircle(width*.8+20,height*.2,20, BLUE);
   tft.fillCircle(width*.8+20,height*.2,10, BLACK);
    // Mouth
   tft.fillCircle(width*.2,height*.8,20,WHITE);
   tft.fillCircle(width*.8,height*.8,20,WHITE); // oblong fillCircle
   tft.fillRect(width*.2,height*.8-20,width*.6,41,WHITE);
   delay(1000);

   // Eyes Narrow
   tft.fillRect(0,height*.2-20,width,10,BLACK);
   tft.fillRect(0,height*.2+10,width,11,BLACK);
   delay(1000);
   
   // Eyes Big
   tft.fillCircle(width*.1,height*.2,30,WHITE);
   tft.fillCircle(width*.1+40,height*.2,30,WHITE); // oblong fillCircle
   tft.fillRect  (width*.1,height*.2-30,45,61,WHITE);
   tft.fillCircle(width*.1+20,height*.2,20,BLUE);
   tft.fillCircle(width*.1+20,height*.2,10,BLACK);
   tft.fillCircle(width*.78,height*.2,30,WHITE);
   tft.fillCircle(width*.78+40,height*.2,30,WHITE); // oblong fillCircle
   tft.fillRect  (width*.78,height*.2-30,45,61,WHITE);
   tft.fillCircle(width*.78+20,height*.2,20,BLUE);
   tft.fillCircle(width*.78+20,height*.2,10,BLACK);
   // Big Mouth
   tft.fillCircle(width*.2,height*.8,30,WHITE);
   tft.fillCircle(width*.8,height*.8,30,WHITE); // oblong fillCircle
   tft.fillRect(width*.2,height*.8-30,width*.6,61,WHITE);
   tft.fillCircle(width*.2,height*.8,20,BLACK);
   tft.fillCircle(width*.8,height*.8,20,BLACK); // oblong fillCircle
   tft.fillRect(width*.2,height*.8-20,width*.6,41,BLACK);
   delay(1000);
   tft.fillRect(0,0,width,height,BLACK); // Erase 

   // Eyes Right
   tft.fillCircle(width*.1,height*.2,20,WHITE);
   tft.fillCircle(width*.1+40,height*.2,20,WHITE); // oblong fillCircle
   tft.fillRect  (width*.1,height*.2-20,40,41,WHITE);
   tft.fillCircle(width*.1+35,height*.2,20, BLUE);
   tft.fillCircle(width*.1+35,height*.2,10, BLACK);
   tft.fillCircle(width*.8,height*.2,20,WHITE);
   tft.fillCircle(width*.8+40,height*.2,20,WHITE); // oblong fillCircle
   tft.fillRect  (width*.8,height*.2-20,40,41,WHITE);
   tft.fillCircle(width*.8+35,height*.2,20, BLUE);
   tft.fillCircle(width*.8+35,height*.2,10, BLACK);
   // Narrow Mouth
   tft.fillCircle(width*.2,height*.8,10,WHITE);
   tft.fillCircle(width*.8,height*.8,10,WHITE); // oblong fillCircle
   tft.fillRect(width*.2,height*.8-10,width*.6,21,WHITE);
   delay(1000);
   
   // Eyes Left
   tft.fillCircle(width*.1,height*.2,20,WHITE);
   tft.fillCircle(width*.1+40,height*.2,20,WHITE); // oblong fillCircle
   tft.fillRect  (width*.1,height*.2-20,40,41,WHITE);
   tft.fillCircle(width*.1+5,height*.2,20, BLUE);
   tft.fillCircle(width*.1+5,height*.2,10, BLACK);
   tft.fillCircle(width*.8,height*.2,20,WHITE);
   tft.fillCircle(width*.8+40,height*.2,20,WHITE); // oblong fillCircle
   tft.fillRect  (width*.8,height*.2-20,40,41,WHITE);
   tft.fillCircle(width*.8+5,height*.2,20, BLUE);
   tft.fillCircle(width*.8+5,height*.2,10, BLACK);
    // Mouth
   tft.fillCircle(width*.2,height*.8,10,WHITE);
   tft.fillCircle(width*.8,height*.8,10,WHITE); // oblong fillCircle
   tft.fillRect(width*.2,height*.8-10,width*.6,21,WHITE);
   delay(1000);

}

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();
}

Monday, March 7, 2022

I am Making my Third Humanoid Robot

I have started on making my third humanoid robot.  This one is modeled after the EZ-Robot JD Humanoid.  The issue with the larger humanoids is that their center of gravity is way too high.  There is a two degree tolerance in each servo and that is amplified by the distance from the servo's.  So in a humanoid that is over 16" tall the two degrees can amount to falling over frontwards or falling over backwards.  That makes it really hard to write software for walking.  

One solution is to make the robot shorter and to make the distance from each servo shorter.  In the following picture there is a servo for the EZ_Robot on the left, for the Hadron Robot in the middle, and for the mechanical robot sold on eBay on hte right.  The EZ-Robot assembly is so short that the ears need to be cut off the one end of the servo for it to work.  The Hadron robot on the other hand is not much smaller than the mechanical version, it also is not quite square.


As I tried more options the possibilities expanded to five different versions.  I think I will have to design my own!


The robot body would take 16 hours to print as designed.  I turned it over and that reduced the time to 10 hours.  However since there would be supports under the front, the front surface is not a smooth.  
Then I ran into the issue with the shoulder servos needing their tabs cut off.  What is it with the designers and cutting the mounting tabs off the servos??


My solution was to cut some slots in the top for the servo mounting tabs.  I used a soldering iron to do that trick.  BTW when I added the legs the body broke in half!  These parts fit way too tight.  I file them off so they are smooth before even trying to fit them together.

The robot is now about 1/2 way completed.  Here is what he looks like so far.

The next issue was that the shoulders (Servo horn extenders) keep breaking in half.  So I rotated them so they stand up before printing them and that seems to fix the issue.


The U brackets for the legs kept breaking.  So I developed my own design.  

So far I have come up with six different servo U bracket design options.  The five on the left do not require you to cut off the servo mounting tabs and they do not break as easily as the ones normally used for this robot.  Somehow I lost the mounting holes in the fifth one but I added them back in later on.


So far he is coming together. The head has too big of an opening for the LCD screen.  I cut it for a 2.5" LCD but then the screen did not fit because the LCD circuit board was too big.  I may have to make a bezel for the LCD to cover the mistakes.....

I almost gave up on his hands.  I have piles of servos but none are the size that properly fit his hands.  There is a size of servo that is in between the SG90/HS55 and the normal sized servo (They are marked "PKZ1060") but even they do not fit.  So I modified the hands to use the SG90 sized servos.  I had to drill out the servo end so the white servo arm would fit through it then I melted a hole for the screw that locks the arm to the printed arm.


I had to remove the left side (It broke off anyway) and then trim a little for the round part of the servo to fit.  Then I used lots of glue to hold the servo in place.  I had trouble with mounting the hands to the arms so I added a screw, as can be seen below the servo in this picture.


Here is what he looks like with his hands attached.  Now to add a servo controller.


This next picture is a size comparison.  JD Humanoid is in the front left.  To the right is the Robosoul HS3 and behind them is the humanoid that is sold on eBay.










Simple Arduino TFT LCD Robot eyes

I am working on making some better "eyes" for my humanoid robots. The 8x8 LED design was cool but I can do a lot more with an LCD screen.  I need to make it more universal to work with different sizes of screens.


This is a link to the video of this robot head being printed:

Here is the code so far:
// Program for Eyes on a 1.8" TFT LCD Screen

#include <TFT.h>  // Arduino LCD library
#include <SPI.h>
 
// Pins
#define cs   10
#define dc   9
#define rst  8
 
// Create an instance of the library
TFT TFTscreen = TFT(cs, dc, rst);
 
void setup() {
 
   // Initialize the screen
   TFTscreen.begin();
 
   // Clear the screen
   TFTscreen.background(0, 0, 0);
 
   // 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.noStroke();
   // Eyes Center
   TFTscreen.fill(255,255,255);
   TFTscreen.circle(20,60,20);
   TFTscreen.circle(50,60,20); // oblong circle
   TFTscreen.rect(20,40,30,41);
   TFTscreen.fill(255,0,0);
   TFTscreen.circle(35,60,20);
   TFTscreen.fill(0,0,0);
   TFTscreen.circle(35,60,10);

   TFTscreen.fill(255,255,255);
   TFTscreen.circle(110,60,20);
   TFTscreen.circle(140,60,20);// oblong circle
   TFTscreen.rect(110,40,30,41);
   TFTscreen.fill(255,0,0);
   TFTscreen.circle(125,60,20);
   TFTscreen.fill(0,0,0);
   TFTscreen.circle(125,60,10);
   delay(1000);

   // Eyes Narrow
   TFTscreen.fill(0,0,0);
   TFTscreen.rect(0,40,160,10);
   TFTscreen.rect(0,70,160,11);
   delay(1000);
   
   // Eyes Big
   TFTscreen.fill(255,255,255);
   TFTscreen.circle(30,60,30);
   TFTscreen.circle(40,60,30); // oblong circle
   TFTscreen.rect(20,40,30,41);
   TFTscreen.fill(255,0,0);
   TFTscreen.circle(35,60,20);
   TFTscreen.fill(0,0,0);
   TFTscreen.circle(35,60,10);

   TFTscreen.fill(255,255,255);
   TFTscreen.circle(120,60,30);
   TFTscreen.circle(130,60,30);// oblong circle
   TFTscreen.rect(110,40,30,41);
   TFTscreen.fill(255,0,0);
   TFTscreen.circle(125,60,20);
   TFTscreen.fill(0,0,0);
   TFTscreen.circle(125,60,10);
   delay(1000);
   TFTscreen.fill(0,0,0);
   TFTscreen.rect(0,30,160,61); // Erase eyes


   // Eyes Right
   TFTscreen.fill(255,255,255);
   TFTscreen.circle(20,60,20);
   TFTscreen.circle(50,60,20); // oblong circle
   TFTscreen.rect(20,40,30,41);
   TFTscreen.fill(255,0,0);
   TFTscreen.circle(20,60,20);
   TFTscreen.fill(0,0,0);
   TFTscreen.circle(20,60,10);

   TFTscreen.fill(255,255,255);
   TFTscreen.circle(110,60,20);
   TFTscreen.circle(140,60,20);// oblong circle
   TFTscreen.rect(110,40,30,41);
   TFTscreen.fill(255,0,0);
   TFTscreen.circle(110,60,20);
   TFTscreen.fill(0,0,0);
   TFTscreen.circle(110,60,10);
   delay(1000);
   
   // Eyes Left
   TFTscreen.fill(255,255,255);
   TFTscreen.circle(20,60,20);
   TFTscreen.circle(50,60,20); // oblong circle
   TFTscreen.rect(20,40,30,41);
   TFTscreen.fill(255,0,0);
   TFTscreen.circle(50,60,20);
   TFTscreen.fill(0,0,0);
   TFTscreen.circle(50,60,10);

   TFTscreen.fill(255,255,255);
   TFTscreen.circle(110,60,20);
   TFTscreen.circle(140,60,20);// oblong circle
   TFTscreen.rect(110,40,30,41);
   TFTscreen.fill(255,0,0);
   TFTscreen.circle(140,60,20);
   TFTscreen.fill(0,0,0);
   TFTscreen.circle(140,60,10);
   delay(1000);
 
}