Skip to main content
Social mediaSocial mediaSocial media   Social media   Social mediaSocial media   Social media

How to make Robot Eyes with OLED display ?

Robot Eyes for robotic projects

How to make robot eyes in a simple way with an OLED display? In this blog, I am going to explain with the help of pictures and the code.

Robotic eyes make your robotic project very interactive. It depends on the specific goals and applications of the project. Robotic eyes with displays offer a wide range of benefits across various robotics projects.
Robot Eyes
There are different types of projects for robot eyes that have their own requirements. but I am going to explain the simple blinking eyes with an OLED display and Arduino. This is very useful for beginners and learners to understand the level of robotic parts.

Material Required

1- Arduino Uno                                                  01 No
2- OLED 0.96”(128x64)(with I2C interface )     01 No
3- Jumper wires                                                04 No’s
4- Breadboard (Optional )                                 01 No                                                

This is a simple project that is part of a robot or robotic project. You can also use an Arduino uno or Nano, for OLED, I used a 0.96” led display. You also need some jumper wires. Connect the wires according to the figure below.
Robot Eyes

Wiring Connections


Arduino uno       OLED display
+5V                         +5V
- VE                        - VE
  A 4                         SDA(Data)
 A 5                        SCL(Clock)
1. Connect VCC and GND:
Connect the VCC pin of the OLED display to the 5V output on the Arduino.
Connect the GND pin of the OLED display to one of the GND pins on the Arduino.

2. Connect SDA and SCL (I2C Interface):
Find the SDA (data) and SCL (clock) pins on your Arduino board (usually A4 for SDA and A5 for SCL on Arduino Uno).
Connect the SDA pin of the OLED display to the SDA pin on the Arduino.
Connect the SCL pin of the OLED display to the SCL pin on the Arduino.

Upload the Sketch with Arduino IDE

To upload a program in Arduino uno with an Arduino IDE environment. Connect Arduino with USB cable to your laptop and open Arduino IDE.
Select the correct board and port under Tool>Board and Tool>Port in the Arduino IDE. Click the Upload button (right arrow icon) in the Arduino IDE to upload the sketch to your Arduino board.

Installing Libraries

Now you need to add these libraries to arduino ide;
1- SPI.h
2- Wire.h
3- Adafruit_GFX.h
4- Adafruit_SSD1306.h

1.  Open the Arduino IDE on your computer.
2.  Go to sketch>Include Library>Manage Libraries.
3.  In the Library Manager, search for “Adafruit SSD1306” and install the library by Adafruit. Same steps to be required for other libraries installation.

Every display has its own address , so please make sure the correct address is mentioned in your program. I use 0x3C according to my display.

How It Works?

With an OLED display, animation can be displayed by changing images randomly, giving the impression of movement. You can download images of shapes or faces from different websites, and convert it to byte arrays and use it in your program. I will explain this method in my upcoming article.

The second and easiest method is go to Lopaka app, in the Library area, select your display and generate shape of eyes. This sketch consists of two parts.
Open Eyes
Closed Eyes
Even Though, smiley faces and many more animations can be generated.

Robot Eyes Program

#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels

// Declaration for SSD1306 display connected using I2C
#define OLED_RESET     -1 // Reset pin # (or -1 if sharing Arduino reset pin)
#define SCREEN_ADDRESS 0x3C
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

#define BLINK_INTERVAL 1000 // Blink interval in milliseconds

// Button pin
#define BUTTON_PIN 2

// States for eye blinking
enum EyeState {
  OPEN,
  CLOSED
};

EyeState eyeState = OPEN;
unsigned long lastBlinkTime = 500;

void setup() {
  Serial.begin(9600);

  pinMode(BUTTON_PIN, INPUT_PULLUP);

  // Initialize the OLED object
  if (!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
    Serial.println(F("SSD1306 allocation failed"));
    for (;;); // Don't proceed, loop forever
  }

  // Clear the buffer.
  display.clearDisplay();
  display.display();
  delay(2000);
}

void loop() {
  // Check if it's time to blink the eyes
  if (millis() - lastBlinkTime >= BLINK_INTERVAL) {
    if (eyeState == OPEN) {
      // Close eyes
      display.clearDisplay();
      display.fillRect(20, 22, 31, 10, WHITE);
      display.fillRect(75, 22, 31, 10, WHITE);
      display.display();
      eyeState = CLOSED;
    } else {
      // Open eyes
      display.clearDisplay();
      display.fillRect(20, 14, 31, 24, WHITE);
      display.fillRect(75, 14, 31, 24, WHITE);
      display.display();
      eyeState = OPEN;
    }
    lastBlinkTime = millis();
  }

  // Check button press to trigger happy face
  if (digitalRead(BUTTON_PIN) == LOW) {
    display.clearDisplay();
    display.display();
    delay(2000); // Display happy face for 2 seconds
    // After displaying, clear the display to return to normal
    display.clearDisplay();
    lastBlinkTime = millis(); // Reset blink timer to maintain blinking pattern
  }
}

Testing the Project

Once uploaded, the Arduino will display eye-like graphics or animations on the OLED display. You can customize the code further to add more complex animations, blinking effects, or interactive behavior based on sensor inputs.
This basic project serves as a starting point for creating robot eyes using Arduino and an OLED display. Feel free to expand and customize the project based on your creativity and requirements!

Popular posts from this blog

Electronic components list with Images and Symbols

Electronic components function and details Electronic components are used in electronics circuits. These components might be PCB mounted or integrated type, widely used in electronics devices. Digital computers, control devices in industries and household items containing large number of integrated components. It is essential to know how to identify circuit board parts, whether you are an electronic technician or engineer. We made the electronics devices with integrated chips and circuit components. In circuits, electronic components are used. What are active and passive components? Types of electronic components? There are two major types of electronic components . In electronic circuits, there are active and passive components. 1- Active components 2- Passive components Active components These types of components operate with external power supplies.  Passive components Passive components do not require an external power supply. These components energize with circuit signals. ...

Arduino UNO Pinout with schematic Diagram and Functions

Arduino UNO Pinout and Board components detail The Arduino Uno is a microcontroller board based on the ATmega328P. It has a total of 28 pins, including digital I/O pins, analog input pins, and power pins. Below is a detailed description of the pin functions It offers extensive resources and a wealth of project ideas, making it a go-to choice for educational purposes, prototyping, and a myriad of DIY electronics projects. The  Arduino UNO Pins  and function are described here in details.  Arduino Uno  is a standard board of the company, even though other boards, e.g. micro, Nano, mega, Leonardo, 101, Due and Yen.  Arduino also manufactured IoT (Internet of Things), Bluetooth, GSM/3G, Wi-Fi, and motion sensor boards. Arduino uno Specifications Microcontroller : ATmega328P Operating Voltage : 5V Input Voltage (recommended) : 7-12V Digital I/O Pins : 14 (of which 6 can be used as PWM outputs) Analog Input Pins : 6 DC Current per I/O Pin : 20 mA Flash Memory : ...

Arduino sensors and modules list for Projects.

Arduino Sensors for Electronics Projects What is Sensor? A Sensor is a device used as the primary element that measures physical value and converts it into an electrical signal. Also, we can say that the sensor is a transducer. It measures temperature, distance, light, sound, etc. Sensors and actuators are widely used in Arduino projects. These sensors come with a kit or can be purchased separately. Some of them are compatible with Arduino Uno boards and also Raspberry Pi and other electronic modules. There are a lot of types of Arduino sensor kits available in the market. How many types of Arduino Sensors? There are a lot of sensors used in electronics projects , e.g. robotics cars, moving objects, flying drones, IoT(internet of things), sound and light operation, etc. Here is a list of 45 in 1 electronic sensor that comes with an Arduino sensors kit , and the details of their applications. Analog temperature Sensors KY 013 Temperature Sensor KY-013 is an analog temperature sensor...

Led Matrix display interface with Arduino uno

LED matrix display pins with Arduino Interface    An 8x8 LED matrix is a grid of 64 LEDs arranged in 8 rows and 8 columns. It is commonly used in  various display and lighting applications, such as digital clocks, scrolling text displays, and graphical displays. Each LED can be controlled individually to create patterns, animations, or characters. I will introduce 788bs as a common anode red color 8x8 LED matrix display m odule. We use it in many electronics displaying items, e.g. electronic clocks. also for moving message displays, displaying games, etc. We use a dot matrix display with an Arduino UNO board directly, sometimes in projects. But for some projects, we use a max7219 chip or 74hc595 for dot matrix driver as required in our projects. led Matrix 8x8 Pin Configuration Each LED matrix can have a slightly different pin configuration, but a common arrangement is as follows: [LED Matrix] Pin 1 - Row 1 Pin 2 - Row 2 Pin 3 - Row 3 Pin 4 - Row 4 Pin 5 - Row 5 Pin ...

555 Timer IC, Pinout and Function details

555 Timer IC Pinout and applications: We widely used 555 timer IC in electronic projects . This chip has multi-function time-based output signals. We can use 555 IC chips with the Arduino or make separate projects. It is available with different brand names, i.e., LM555, NE555, and SE555. But it is originally manufactured by Texas Instruments. The chip is manufactured in different packages, e.g. SOIC, PDIP, VSSOP. For more details, the 555 timer IC datasheet is available at the Texas official site. We use it for time-based operated siren circuits, control motor speed, and operating led flasher circuits. It can produce a lot of functions, e.g., oscillation, Astable. Bistable, Monostable, flip-flop logic, and pulse width modulation. How 555 Timer work ? You can get a lot of solutions from the chip if you want to understand how it works. There are a lot of timer projects and applications, e.g., timer-controlled circuits, sound, LED flashers, and more. 555 Timer IC Pinout The circuit di...

Arduino Kits for beginners in 2024

Arduino Kits for beginners electronics projects Arduino kits are very simple to learn and widely used in electronic projects . You can make your own projects in a few minutes. Making a circuit on a PCB is a hard job, and it requires excellent skills in soldering. Also, it consumes a lot of time. Assembling components is another problem. But electronic portable kits solve the issue. You can gain knowledge from Arduino starter kits on Amazon. It includes project books and different varieties of sensor modules. We directly connect on the breadboard and reconnect in a few steps. Arduino Uno Starter Kit (official) The official starter kit is from the original manufacturer. This is a complete package, including the Arduino Uno kit Manual. This manual has practical images and schematic diagrams to understand well.   The manual covers not only project-making areas; but also information about Arduino IDE software installation on Windows/macOS X and Linux. Every Project/lesson comprises ...

Resistor Calculator with Graphical Chart

Resistor Calculator for measuring resistance Resistor calculator is a very useful tool for anyone working on electronic experiments or projects. It is easy to use and has a simple design. To get resistance for Led voltage drop or your circuit resistance, you can use an online calculator or look up a formula. We can use it for voltage drops or led current limiting. Online resistor calculator It is a simple and easy-to-use online resistor calculator instead of using formulas. It comes with different bands e.g.3 band, 4, 5, and 6 bands. The program calculates resistor values. # Get in touch with more interesting topics ……… 1- How to use a led Matrix with Arduino . 2- Arduino books for projects . 3- Best Arduino kits for beginners . Standard Table For Calculating 4 Band Resistors Online Resistor Calculator (4 Band) Graphical Resistor Calculator Graphical Resistor Calculator is a Free Software to easil...

"ESP32 GPIO Pinout and Overview: Complete Guide to Pin Functions

ESP32 pinout and functions and details ESP32 module is an Internet of things wireless module. It is used to control the devices through the internet. It is a remote IoT development board that can be easily programmed and controlled via WIFI or Bluetooth.  It has a dual-core Tensilica Xtensa LX6 CPU, which provides ample processing power for  various tasks. It includes GPIO pins, SPI, I2C, UART, ADC, DAC, and more peripherals.  So we can configure  esp32 pins for a wide variety of projects.                     Figure:ESP32 ESP32 development board used arduino ide to program as well as other environments e.g. micro python, Thoni, Scratch 3.0, etc. There are several modules that are part of the ESP 32 family.  ESP32 devkit, ESP wroom-32.  It has a flash memory of 520 k bytes with a working frequency of 240kMHZ. WIFI 802.11, Bluetooth 4.2BR and BLE ...

Arduino Apps and software for genius

  Arduino apps for Android and Windows We know that Arduino Apps is used for programming, but we could run it on Windows and Android. As it depends on the availability of a programming device for our projects. This application also works for the Arduino Bluetooth Android project. These Applications can help to learn and create electronic projects . I will describe the functions and introduction of the following: application and also support systems required to run. List of Arduino programming applications for Android Android Apps for Electronics Solutions. It is an easy-to-use Arduino Application in Apple Android. Arduino Droid app for Mobiles Droid v   4.9.1 . Droid is a short form of Android; it means a robot. The Droid app works on PC and, an example of Arduino Android is also available. It includes IDE, compiler, and up-loader. the mobile memory should be enough, and it can't be set up on an SD card for the Android protection policy. The second picture shows a menu,...

Contact Form

Name

Email *

Message *