Monday, May 23, 2016

MEMBUAT POV DISPLAY ARDUINO

POV display atau PERSISTENCE OF VISION adalah suatu sarana yang di gunakan untuk hiburan atau periklanan yang dapat di aplikasikan pada benda yang bergerak atau berputar , di luar negeri sendiri sudah ada produsen yang membuat POV display salah satu nya Monkey Electric yang membuat pov display berwarna dan digunakan untuk periklanan ataupun style, untuk membuat pov display sederhan dengan arduino komponen yang di butuhkan adalah :


1. Arduino
2. led
3. Bateray 9 v

setelah mempunyai komponen yang di butuhkan sekarang kita lanjutkan membuat sorce code nya :

// defining the picts
 
int off[] = {
  0,0,0,0,0,0,0,0,0,0,0,
  0,0,0,0,0,0,0,0,0,0,0,
  0,0,0,0,0,0,0,0,0,0,0,
  0,0,0,0,0,0,0,0,0,0,0,
  0,0,0,0,0,0,0,0,0,0,0,
  0,0,0,0,0,0,0,0,0,0,0,
  0,0,0,0,0,0,0,0,0,0,0,
  0,0,0,0,0,0,0,0,0,0,0,
  0,0,0,0,0,0,0,0,0,0,0,
  0,0,0,0,0,0,0,0,0,0,0,
  0,0,0,0,0,0,0,0,0,0,0};
 
int heart[] = {
  0,0,0,0,0,0,0,0,0,0,0,
  0,0,1,1,1,1,0,0,0,0,0,
  0,1,1,1,1,1,1,0,0,0,0,
  0,1,1,1,1,1,1,1,0,0,0,
  0,0,1,1,1,1,1,1,1,0,0,
  0,0,0,1,1,1,1,1,1,1,0,
  0,0,1,1,1,1,1,1,1,0,0,
  0,1,1,1,1,1,1,1,0,0,0,
  0,1,1,1,1,1,1,0,0,0,0,
  0,0,1,1,1,1,0,0,0,0,0,
  0,0,0,0,0,0,0,0,0,0,0};
 
int greek[] = {
  1,1,0,0,0,0,0,0,0,0,0,
  1,1,0,0,0,0,0,0,0,0,0,
  1,1,0,0,1,1,1,1,1,1,0,
  1,1,0,0,1,1,1,1,1,1,0,
  1,1,0,0,1,1,0,0,1,1,0,
  1,1,1,1,1,1,0,0,1,1,0,
  1,1,1,1,1,1,0,0,1,1,0,
  0,0,0,0,0,0,0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0,0,0,0,0,0,0,0,0,0,0,
  0,0,0,0,0,0,0,0,0,0,0,
  0,0,0,0,0,0,0,0,0,0,0,
  0,0,0,0,0,0,0,0,0,0,0,
  0,0,0,0,0,0,0,0,0,0,0,
  0,0,0,0,0,0,0,0,0,0,0,
  0,0,0,0,0,0,0,0,0,0,0,
  0,0,0,0,0,0,0,0,0,0,0,
  0,0,0,0,0,0,0,0,0,0,0,
  0,0,0,0,0,0,0,0,0,0,0};
 
int dotTime;
 
// this constant won't change:
const int  buttonPin = 2;    // the pin that the pushbutton is attached to
 
// Variables will change:
int buttonPushCounter = 0;   // counter for the number of button presses
int buttonState = 0;         // current state of the button
int lastButtonState = 0;     // previous state of the button
 
//#include
 
void setup()
{
  // POV setting the ports of the leds to 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);
 
  // defining the time dots appear (ms)
  dotTime = 5;
 
  // initialize the button pin as a input:
  pinMode(buttonPin, INPUT);
 
  // initialize serial communication:
  Serial.begin(9600);
 
}
 
//POV
void printPict(int row[]){
 
  int y;
 
  // printing the y1 row of the pict
  for (y=0; y<11; y++)
  {
    digitalWrite(y+3, row[y]);
  }
  delay(dotTime);
 
  // printing the y2 row of the pict
  for (y=0; y<11; y++)
  {
    digitalWrite(y+3, row[y+11]);
  }
  delay(dotTime);
 
  // printing the y3 row of the pict
  for (y=0; y<11; y++)
  {
    digitalWrite(y+3, row[y+22]);
  }
  delay(dotTime);
 
  // printing the y4 row of the pict
  for (y=0; y<11; y++)
  {
    digitalWrite(y+3, row[y+33]);
  }
  delay(dotTime);
 
  // printing the y5 row of the pict
  for (y=0; y<11; y++)
  {
    digitalWrite(y+3, row[y+44]);
  }
  delay(dotTime);
 
  // printing the y6 row of the pict
  for (y=0; y<11; y++)
  {
    digitalWrite(y+3, row[y+55]);
  }
  delay(dotTime);
 
  // printing the y7 row of the pict
  for (y=0; y<11; y++)
  {
    digitalWrite(y+3, row[y+66]);
  }
  delay(dotTime);
 
  // printing the y8 row of the pict
  for (y=0; y<11; y++)
  {
    digitalWrite(y+3, row[y+77]);
  }
  delay(dotTime);
 
  // printing the y9 row of the pict
  for (y=0; y<11; y++)
  {
    digitalWrite(y+3, row[y+88]);
  }
  delay(dotTime);
 
  // printing the y10 row of the pict
  for (y=0; y<11; y++)
  {
    digitalWrite(y+3, row[y+99]);
  }
  delay(dotTime);
 
  // printing the y11 row of the pict
  for (y=0; y<11; y++)   {     digitalWrite(y+3, row[y+110]);   }   delay(dotTime); }
  void loop() { 
    checkSerial(); printPict(lastPict); } 
  int checkSerial () { 
    //button loop 
  // read the pushbutton input pin:  
  buttonState = digitalRead(buttonPin); 
  // compare the buttonState to its previous state 
  if (buttonState != lastButtonState) {  
    // if the state has changed, increment the counter    
  if (buttonState == HIGH) {   
    // if the current state is HIGH then the button    
    // wend from off to on:  
    buttonPushCounter++;     
  Serial.println("on");    
  Serial.print("number of button pushes:  ");    
  Serial.println(buttonPushCounter, DEC);     }  
  else {    
    // if the current state is LOW then the button    
    // wend from on to off:  
    Serial.println("off");   
    }   }   // save the current state as the last state, 
    //for next time through the loop
    lastButtonState = buttonState;      
    if(buttonPushCounter == 0) {   
    memcpy(lastPict, off, sizeof(lastPict));   } 
    if (buttonPushCounter == 1) {   
    memcpy(lastPict, triangle, sizeof(lastPict));   }   if (buttonPushCounter == 2) {     memcpy(lastPict, diagonal, sizeof(lastPict));   }    if (buttonPushCounter == 3) {     memcpy(lastPict, seta, sizeof(lastPict));   }    if (buttonPushCounter == 4) {     memcpy(lastPict, greek, sizeof(lastPict));   }    if (buttonPushCounter == 5) {     memcpy(lastPict, chakana, sizeof(lastPict));   }      if (buttonPushCounter > 5) {
    buttonPushCounter = 0;
 
  }
    

dari source code di atas output yang di gunakan adalah 11 buah LED yang akan menjadi tampilan sebuah POV display , dapat kita lihat pada source code di atas 0 berarti led OFF dan 1 berarti led ON jadi bilangan 0 dan 1 adalah logika untuk menyalakan dan mematikan LED sesuai urutan nya agar menampilkan informasi atau gambar yang kita buat , cara membuat nya bisa dengan mengkonversi dari Microsoft Excel ataupun sofware konversi Biner, setelah mengcompile source code di atas download ke arduino , untuk konfigurasi LED nya sesuai dengan output source code tersebut yaitu untuk kutub + LED di hubungkan ke PIN 3-13 stelah selesai bisa di coba dengan mengayunkan kekanan dan kekiri apabila berhasil maka akan ditampilkan gambar dan huruf dan posisi led berkedip dengan cepat.

gambar di atas adalah contoh POV display yang telah saya buat.