Persistence of Vision

Autor: Varga Raimond
Grupa: 335CA

Introducere

Proiectul consta in realizarea un POV ce va afișa un text sub forma unei imagini aparent statice.
Textul va putea fi setat prin Bluetooth.
Efectul creat este unul foarte interesant, led-urile rotindu-se cu o viteza suficient de mare, incat
ochiul uman nu le mai percepe individual, acesta observand doar o imagine sau o animatie.

Descriere generală

Partea principala a proiectului o reprezinta banda de led-uri, ce se va roti cu ajutorul unui motor DC.
Pentru a sincroniza aprinderea led-urilor in asa fel incat sa obtin un efect de imagine statica, voi folosi
un senzor Hall si un magnet mic lipit pe placa. Pentru ca placa Arduino se va roti cu led-urile, o voi alimenta
cu ajutorul unei baterii lipite tot pe placa. In final, voi adauga un modul Bluetooth, pentru a putea seta textul
afisat de POV de pe laptop sau telefon.

Hardware Design

Lista componente:

  • Arduino UNO
  • Modul Bluetooth HC-05
  • 8 led-uri
  • 8 rezistente
  • Fire
  • Pini tata
  • Baterie 9V
  • Senzor Hall effect
  • Magnet
  • Placa prototipare cablaj
  • Ventilator 220V
  • Un switch pentru baterie
  • Placa pe care voi monta - carton si lemn
  • Suruburi pentru prinderea placii Arduino
  • Pistol lipit, letcon


In realizarea partii hardware am parcurs urmatoarele etape:

  1. pe un pcb am pus 8 leduri impreuna cu 8 rezistente, legandu-le catodul in comun pentru a-l trage la GND-ul de pe Arduino;
  2. am lipit fire pe anodul fiecarui led, legand apoi led-urile pe pini tata pusi pe Arduino, de la pinul 2 pana la 9;
  3. am fixat pcb-ul cu leduri pe Arduino, folosindu-ma de un pistol cu lipici si de pinii ICSP;
  4. am fixat placa Arduino pe o bucata de carton(pentru a fi cat mai usor ansamblul) folosindu-ma de suruburi si am lipit cu fludor si senzorul de effect Hall la pinul A0;
  5. am lipit modulul Bluetooth pe pinii Rx si Tx ai placutei si l-am fixat apoi sub placa de leduri, pe carton, pentru a-l ascunde;
  6. pe spatele cartonului am atasat bateria cu switch-ul in asa fel incat bateria va putea fi schimbata;
  7. am facut un suport de lemn pe care am prins cu suruburi ventilatorul;
  8. am prins intregul ansamblu cu placa Arduino de mijlocul ventilatorului pentru a putea fi rotit;
  9. in final am lipit pe suportul de lemn si un magnet care activeaza senzorul de efect Hall;

Software Design

Am scris codul in Arduino IDE. La inceput am parcurs cateva variante de pe internet, apoi adaptand totul la componentele mele - vectorii de litere, modificarea prin Bluetooth, sincronizarea prin senzor, etc. Literele afisate sunt reprezentate prin vectori de 30 de elemente. Acestea reprezinta modul de aprindere a ledurilor, fiecare grup de 8 numere constintuind o linie. Pentru ca ventilatorul se invarte in sens trigonometric, vectorii incep de la finalul fiecarei litere.

  1. setup(): functia initializeaza pinii de iesire pentru leduri si de intrare pentru senzorul de effect Hall. De asemenea, stabileste textul afisat initial si activeaza interfata seriala, pentru a comunica cu modulul Bluetooth.
  2. printLetter(): afiseaza, pe rand, grupurile de cate 8 numere(leduri) pentru a scrie litera curenta;
  3. chooseLetter(): un switch care recunoaste litera ce trebuie afisata si transmite mai departe acest lucru;
  4. displayString(): parcurge textul curent de la final (din cauza tipului de rotatie) si trimite fiecare litera spre a fi afisata;
  5. loop(): functia verifica daca s-a primit un nou text prin Bluetooth, pentru a-l schimba pe cel curent si incepe afisarea textului, de fiecare data cand senzorul de effect Hall ajunge la magnet, activandu-se.

Cod arduino

Cod arduino

byte _[] = {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};
byte A[] = {1,1,1,1,1,1,1,1, 0,0,0,0,1,0,0,1, 0,0,0,0,1,0,0,1, 0,0,0,0,1,0,0,1, 1,1,1,1,1,1,1,1};
byte B[] = {0,1,1,1,0,1,1,0, 1,0,0,0,1,0,0,1, 1,0,0,0,1,0,0,1, 1,0,0,0,1,0,0,1, 1,1,1,1,1,1,1,1};
byte C[] = {1,0,0,0,0,0,0,1, 1,0,0,0,0,0,0,1, 1,0,0,0,0,0,0,1, 0,1,0,0,0,0,1,0, 0,0,1,1,1,1,0,0};
byte D[] =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,0,0,0,1,0,1, 1,0,0,0,1,0,0,1, 1,0,0,1,0,0,0,1, 1,1,1,0,0,0,0,1};
String str, newStr;

int letterSpace = 5;
int i;
float delayTime=1;
int state = 500;


void setup() {
  Serial.begin(9600);
  for (i = 2; i < 10 ; i++ ) {
    pinMode(i, OUTPUT); // leduri
  }
  pinMode(A0, INPUT_PULLUP); // senzor efect Hall

  // text initial de afisat
  str = String("HELLO");
}

void printLetter(byte letter[]) {
  int y = 0;
  // afisez pe rand fiecare linie din litera
  for (y = 0; y < 8; y++) {
    digitalWrite(y + 2, letter[y]);
  }
  delay(delayTime);
  for (y = 0; y < 8; y++) {
    digitalWrite(y + 2, letter[y + 8]);
  }
  delay(delayTime);
  for (y = 0; y < 8; y++) {
    digitalWrite(y + 2, letter[y + 16]);
  }
  delay(delayTime);
  for (y = 0; y < 8; y++) {
    digitalWrite(y + 2, letter[y + 24]);
  }
  delay(delayTime);
  for (y = 0; y < 8; y++) {
    digitalWrite(y + 2, letter[y + 32]);
  }
  delay(delayTime);
  // dezactivez ledurile pentru a avea spatiu intre litere
  for (y = 0; y < 8; y++) {
    digitalWrite(y + 2, 0);
  }
  delay(letterSpace);
}

void chooseLetter(char letter) {
  // identific litera curenta
  switch (letter) {
    case 'A':
      printLetter(A);
      break;
    case 'B':
      printLetter(B);
      break;
    case 'C':
      printLetter(C);
      break;
    case 'D':
      printLetter(D);
      break;
    case 'E':
      printLetter(E);
      break;
    case 'F':
      printLetter(F);
      break;
    case 'G':
      printLetter(G);
      break;
    case 'H':
      printLetter(H);
      break;
    case 'I':
      printLetter(I);
      break;
    case 'J':
      printLetter(J);
      break;
    case 'K':
      printLetter(K);
      break;
    case 'L':
      printLetter(L);
      break;
    case 'M':
      printLetter(M);
      break;
    case 'N':
      printLetter(N);
      break;
    case 'O':
      printLetter(O);
      break;
    case 'P':
      printLetter(P);
      break;
    case 'Q':
      printLetter(Q);
      break;
    case 'R':
      printLetter(R);
      break;
    case 'S':
      printLetter(S);
      break;
    case 'T':
      printLetter(T);
      break;
    case 'U':
      printLetter(U);
      break;
    case 'V':
      printLetter(V);
      break;
    case 'W':
      printLetter(W);
      break;
    case 'X':
      printLetter(X);
      break;
    case 'Y':
      printLetter(Y);
      break;
    case 'Z':
      printLetter(Z);
      break;
    default:
      printLetter(_);
      break;
  }
}

void displayString(String s) {
  for (i = str.length() - 1; i >= 0; i--) {
    chooseLetter(str[i]);
  }
}

void loop() {
  if (Serial.available() > 0) {
    newStr = Serial.readString();
    if (newStr != "\n") {
      str = String(newStr);
    }
  }
  state = analogRead(A0);
  if (state < 538) {
    displayString(str);
  } else {
    state = analogRead(A0);
  }
}

Rezultate obtinute

Proiectul este functional. Initial afiseaza 'Hello', textul putand fi modificat foarte usor prin Bluetooth de pe orice dispozitiv. In demo, modific de pe laptop trimitand text direct spre modulul Bluetooth din Arduino IDE. Am mai testat si folosind aplicatia ArduinoBlue de pe AppStore, cu acelasi rezultat. In demo textul nu se vede perfect, nu am reusit sa filmez in asa fel incat sa se vada ca in realitate, pierzandu-se din calitate in momentul inregistrarii.
Sunt multumit si de aspect si de functionalitata proiectului. Rezultatul final este urmatorul:

Demo proiect

Concluzii

A fost primul proiect hardware pe care l-am realizat, faptul ca in final am obtinut un POV functional reprezinta o mare satisfactie. A fost mult mai greu decat ma asteptam, de la stabilirea design-ului pentru a fi cat mai usor si durabil, pana la lipirea tuturor firelor cu letconul.
Regret ca in filmulete nu se vede chiar ca in realitate, dar sunt multumit de calitatea pe care am obtinut-o in final.

Jurnal

25.04.2021 : Alegere tema, completare introducere, schema initiala si componente necesare.
25.05.2021 : Modifcare lista componente, adaugare schema Eagle, completat Software Design.
25.05.2021 : Completat Hardware Design, adaugare rezultate finale + demo.
25.05.2021 : Concluzii si modificari finale.

Bibliografie/Resurse

pm/prj2021/alazar/persistence-of-vision.txt · Last modified: 2021/05/25 21:19 by raimond.varga
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0