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!

Comments

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. Elec

Arduino UNO Pins (Diagram) Learn quickly pins function

Arduino UNO Pinout and Board components detail The Arduino Uno board is an electronic experimental board. Atmega328P is the heart of the Arduino board. This is an open-source platform for creating electronics projects. I will explain the description of the  Arduino UNO Pins  and the board in the post.  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.                                                                        FIG-A Arduino Uno board The Atmega328P Microcontroller is 8bit with 32k byte internal flash memory. To program the main chip, a 16 MHz crystal is part of the board. The Arduino board requires only 5V DC to operate. Arduino Uno pinout detail The Arduino UNO board has 5 analog and 14 digital (PWM) pins. These pins could be GPIO or used for specific signals. Vin Pin We use a Vin pin for 7-12 VD

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

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 exam

Led Matrix display interface with Arduino uno

8x8 LED matrix display with Arduino and Pins description There are several types of led matrices available in the market. We can differentiate it as per the size and types of connection, e.g. 5x7, 8x8, common anode, and common cathode type. It comes in different single colors and RGB. But in this article, I will discuss 788bs as a common anode red color 8x8 LED matrix display Module. 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 Pinout function detail The led matrix modules are used in various colors, but I specifically describe the red led matrix. It is very easy to interface a 788bs led matrix with an Arduino board as compared to an RGB led display. If we look at a piece of the 8x8 dot mat

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

"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 technology. Input and output pins, i2c pins, digital to analog converter. Wi-fi

Best Electronic Books for beginners in 2024

Electronic books with Kindle editions A wonderful variety of electronic books . Those who have a very basic knowledge of electronic components. These books are very useful. You can understand the basic structure of the electronic components. These are helpful for theory and practical purposes. What is an electronics book and how to read it? T he book is called an electronic or E-book if it is available for online reading. It might be in pdf format and available to download . Getting Started in Electronics Third Edition, Writer - Forrest M Mims III 128 Pages This book starts with the basic concept, from electricity to electronics. It deals with basic tools and items used to start a mini-project. In this book, the semiconductor-type materials and components are described. The book is about semiconductor components and photonic semiconductor components. It provides logic and symbols of logic gates and integrated circuits. Either digital integrated circuits or linear integrated circuits (

Temperature Converter with Temperature conversion Formula

Temperature Converter Temperature Converter Enter temperature: Select unit: Celsius Fahrenheit Kelvin Convert A temperature converter is a handy tool in our daily life. It is quite easy to get the conversion of temperature between different units. We can also calculate temperature by using the temperature conversion formula.  In electronics circuits , temperature sensors are commonly employed for many tasks, such as  temperature monitoring and detection of overheating issues.    Usually, the Celsius scale displays the atmosphere's temperature, but for humans, temperature is measured in Fahrenheit. Temperature Converter Formula Temperature converter formula to find values in Celsius to Fahrenheit, Kelvin, and Rankine according

Contact Form

Name

Email *

Message *