Friday, May 15, 2015

Arduino Based POV Display

A persistence of vision (PoV) display is a row of LED's that flash out columns of a message.  When the array of LED's is moved, like when mounted on a fan lief or any rotating platform, the message can be read as if it were many LED's wide, instead of a single row. The purpose of our POV display  is to create a small apparatus that will create a visual using only a small number of LEDs as it spins in a circle. When the LEDs rotate several times around a point in less than a second, the human eye reaches its limit of motion perception and creates an illusion of a continuous image. Therefore, our POV display demonstrates this phenomenon by creating a visual as the LEDs spin rapidly in a circle and the person watching will see one continuous image. 

 Persistence Of Vision (PoV) Display




The hardware setup for a PoV display is fairly straightforward, but this instructable contains code where the display can be controlled and programmed readily over the serial connection, and display settings can be saved so that they are automatically loaded and run when powered up from a battery.

You will want an Arduino AVR microcontroller board, such as an Uno, Nano, or mini.  And 8 LED's, and 8 resistors from about 100 to 220 ohms.

For our example, we will assume a 10 LED display.  Wire the LED's in series with a resistor to digital I/O pins 3-10, and arrange them in a straight row.

CONNECTION DIAGRAM

// JAWAHARLAL COLLEGE OF ENGINEERING AND TECHNOLOGY
//Code for 8 LED Persistence Of Vision (POV) Display
//data corresponding to the each alphabet and a few characters to be displayed
byte A[]={B01111111,B10001000,B10001000,B10001000,B10001000,B01111111,B00000000,B00000000};
byte B[]={B11111111,B10001001,B10001001,B10001001,B10001001,B01110110,B00000000,B00000000};
byte C[]={B01111110,B10000001,B10000001,B10000001,B10000001,B10000001,B01000010,B00000000};
byte D[]={B11111111,B10000001,B10000001,B10000001,B10000001,B01111110,B00000000,B00000000};
byte E[]={B11111111,B10010001,B10010001,B10010001,B10010001,B10010001,B10010001,B00000000};
byte F[]={B11111111,B10010000,B10010000,B10010000,B10010000,B10010000,B10010000,B00000000};
byte G[]={B11111111,B10000001,B10000001,B10001101,B10001001,B10001001,B10001001,B10001111};
byte H[]={B11111111,B00001000,B00001000,B00001000,B00001000,B00001000,B00001000,B11111111};
byte I[]={B10000001,B10000001,B10000001,B11111111,B10000001,B10000001,B10000001,B00000000};
byte J[]={B10000010,B10000001,B10000001,B11111111,B10000000,B10000000,B10000000,B00000000};
byte K[]={B11111111,B00101000,B01000100,B10000010,B00000001,B00000000,B00000000,B00000000};
byte L[]={B11111111,B00000001,B00000001,B00000001,B00000001,B00000001,B00000001,B00000000};
byte M[]={B11111111,B01000000,B00100000,B00010000,B00100000,B01000000,B11111111,B00000000};
byte N[]={B11111111,B01000000,B00100000,B00010000,B00001000,B00000100,B00000010,B11111111};
byte O[]={B01111110,B10000001,B10000001,B10000001,B10000001,B01111110,B00000000,B00000000};
byte P[]={B11111111,B10001000,B10001000,B10001000,B10001000,B10001000,B01110000,B00000000};
byte Q[]={B01111100,B10000010,B10000010,B10001010,B10001111,B01111101,B00000000,B00000000};
byte R[]={B11111111,B10011000,B10010100,B10010010,B11100001,B00000000,B00000000,B00000000};
byte S[]={B01110001,B10001001,B10001001,B10001001,B10001001,B10001001,B10001001,B10000110};
byte T[]={B10000000,B10000000,B10000000,B11111111,B10000000,B10000000,B10000000,B00000000};
byte U[]={B11111100,B00000010,B00000001,B00000001,B00000001,B00000001,B00000010,B11111100};
byte V[]={B11000000,B00010000,B00000100,B00000001,B00000100,B00010000,B11000000,B00000000};
byte W[]={B11111111,B00000010,B00000100,B00001000,B00000100,B00000010,B11111111,B00000000};
byte X[]={B10000001,B01000010,B00100100,B00011000,B00011000,B00100100,B01000010,B10000001};
byte Y[]={B00000000,B11100000,B01100000,B00100000,B00111111,B00110000,B01100000,B11100000};
byte Z[]={B10000001,B11000001,B10100001,B10010001,B10001001,B10000101,B10000011,B10000001};
byte fullstop[]={B00000000,B00000000,B00000000,B00000011,B00000011,B00000000,B00000000,B00000000};
byte comma[]={B00000000,B00000000,B00000000,B00000110,B00000101,B00000000,B00000000,B00000000};
byte heart[]={B00100000,B11111000,B01111110,B00111111,B00111111,B01111110,B11111000,B00100000};
byte smile[]={B01011100,B11000110,B01000011,B00000001,B00000001,B01000011,B11000110,B01011100};
byte zero[]={B11111111,B10000001,B10000001,B10000001,B10000001,B10000001,B10000001,B10000001,};
byte one[]={B00010001,B00100001,B01000001,B11111111,B00000001,B00000001,B00000001,B00000000};
byte two[]={B00100001,B01000010,B10000101,B10000001,B10001001,B10000001,B10010001,B01100001};
byte three[]={B10010001,B10010001,B10010001,B10010001,B10010001,B10010001,B10010001,B11101111};
byte four[]={B00001000,B00011000,B00101000,B01001000,B11111111,B00001000,B00001000,B00001000};
byte five[]={B11110010,B10010001,B10010001,B10010001,B10010001,B10010001,B10010010,B10001100};
byte blank[]={B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000};

//  Changeable parameters

int pins[] = {2,3,4,5,6,7,8,9};  // an array of pin numbers
int rows= 8; // total LED's in a row
int timer1 = 1; // time between columns (milliseconds)
int timer2 = 7; // time between frames (milliseconds)
int frame_len = 8;  // frame length
int hallPin = 10;  //Hall Effect sensor pin number
int hallState = 0;  //initialize Hall Effect sensor as 0

void setup()
{
  int i;
  pinMode(10, INPUT);
  for (i = 0; i < rows; i++)
    pinMode(pins[i], OUTPUT); // set each LED pin as an output
}

void loop()
{

  hallState = digitalRead(hallPin);

  if (hallState == LOW) {    
  // turn LED on:  
  //Max number: 12 letters
//Change the letters in bracket for Displaying charactrs.
  delay(timer1);
  show(F);
  delay(timer1);
  show(E);
  delay(timer1);
  show(L);
  delay(timer1);
  show(I);
delay(timer1);
  show(X);

delay(timer2);
delay(timer2);
delay(timer2);
  //Change show() to display different letters or images
}
  else
  {
    PORTD = B00000000; //turn off LEDs
  }
}

void show( byte* image )
{
  int a,b,c;

  // read every data for all columns in each frame.
    for (b = 0; b < frame_len; b++)
    {
      for (c = 0; c < rows; c++)
      {
        digitalWrite(pins[c], bitRead(image[b], c));
      }
      delay(timer1);
    }
    for (c = 0; c < rows; c++)
    {
      digitalWrite(pins[c], LOW);
    }
}