Project tutorial
Magic Eyes

Magic Eyes © CERN-OHL

I built a project using 8x8 LED matrix without using MAX7219 or any extra library files because they make code difficult to understand.

  • 723 views
  • 0 comments
  • 3 respects

Components and supplies

Apps and online services

About this project

I wanted to make a project using 8x8 LED matrix without the help of MAX7219 and without adding any of the libraries.

So, I created Magic Eyes - a fun project which act as kind of humans. When something comes very close to us, our eyes closes on its on because of stimuli. I have done the same thing with my project.

I wanted it to be different, cheap and playful. If you use Max7219 circuit with it, it will be cost you around {2*(AU $5.54)}, while if you use only led matrix, it will cost around {2*(AU $0.8)}. I don't want to add any libraries because from them, we can't understand the code.

Code

Led MatrixArduino
//Simply connect all the pins as shown in diagram
//You need to connect 220 ohm resistor to save the led matrix.
#define ROW_1 2
#define ROW_2 3
#define ROW_3 4
#define ROW_4 5
#define ROW_5 6
#define ROW_6 7
#define ROW_7 8
#define ROW_8 9

#define COL_1 10
#define COL_2 11
#define COL_3 12
#define COL_4 13
#define COL_5 A0
#define COL_6 A1
#define COL_7 A2
#define COL_8 A3

const byte rows[] = {ROW_1, ROW_2, ROW_3, ROW_4, ROW_5, ROW_6, ROW_7, ROW_8};

//if you want to change the design, put your changes in design line wise
byte OPEN[] = 
{
  B00111100,                             //    ****  
  B01000010,                             //   *    *
  B10011001,                             //  *  **  *
  B10111101,                             //  * **** *
  B10111101,                             //  * **** *
  B10011001,                             //  *  **  *
  B01000010,                             //   *    * 
  B00111100                              //    ****
};

byte CLOSE[] = 
{
  B00111100,                             //    ****  
  B01000010,                             //   *    *
  B10000001,                             //  *      *
  B10000001,                             //  *      *
  B10000001,                             //  *      *
  B10000001,                             //  *      *
  B01000010,                             //   *    * 
  B00111100                              //    ****
};


void setup() 
{
  Serial.begin(9600);
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(7, OUTPUT);
  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(11, OUTPUT);
  pinMode(12, OUTPUT);
  pinMode(13, OUTPUT);
  pinMode(A0, OUTPUT);
  pinMode(A1, OUTPUT);
  pinMode(A2, OUTPUT);
  pinMode(A3, OUTPUT);

  pinMode(A4, INPUT);
}

void loop() 
{
  if((digitalRead(A4))==0)
  {
    drawScreen(OPEN);
  } 
  else
  {
    drawScreen(CLOSE);
  } 
}

void  drawScreen(byte buffer2[])
{
  // Turn on each row in series
  for (byte i = 0; i < 8; i++) 
  {
    setColumns(buffer2[i]); // Set columns for this specific row
    digitalWrite(rows[i], HIGH);
    digitalWrite(rows[i], LOW);
  }
}


void setColumns(byte b) 
{
  digitalWrite(COL_1, (~b >> 0) & 0x01); // Get the 1st bit: 10000000
  digitalWrite(COL_2, (~b >> 1) & 0x01); // Get the 2nd bit: 01000000
  digitalWrite(COL_3, (~b >> 2) & 0x01); // Get the 3rd bit: 00100000
  digitalWrite(COL_4, (~b >> 3) & 0x01); // Get the 4th bit: 00010000
  digitalWrite(COL_5, (~b >> 4) & 0x01); // Get the 5th bit: 00001000
  digitalWrite(COL_6, (~b >> 5) & 0x01); // Get the 6th bit: 00000100
  digitalWrite(COL_7, (~b >> 6) & 0x01); // Get the 7th bit: 00000010
  digitalWrite(COL_8, (~b >> 7) & 0x01); // Get the 8th bit: 00000001
  // If the polarity of your matrix is the opposite of mine
  // remove all the '~' above.
}

Schematics

Circuitous
Simply do the connection as done in the image and put Infrared sensor at PIN A4. Provide Vin and GND to both Infrared sensor and Arduino.
Untitled zs5knrp2xe

Comments

Similar projects you might like

Magic Projector (A Romantic One)

Project tutorial by Arturo Rosete

  • 1,482 views
  • 1 comment
  • 7 respects

Ask the Magic 8 Ball!

Project tutorial by Team College Bound

  • 1,791 views
  • 0 comments
  • 7 respects

Magic Cauldron

Project showcase by Ian McKay

  • 5,866 views
  • 3 comments
  • 21 respects

Magic Lamp

by Nekhil ravi

  • 3,178 views
  • 3 comments
  • 33 respects

LED Color Sequencer

Project tutorial by thefantasticode.Group

  • 4,319 views
  • 10 comments
  • 15 respects

AI LCD friend!

Project tutorial by aip06

  • 3,273 views
  • 8 comments
  • 7 respects
Add projectSign up / Login