====== AC giant led matrix ======
===== Goals =====
* allumer une matrice de led alphanumérique sur plusieurs dizaine de mètres
===== Ressources =====
* collab [[user:jeanneret|nico]] , [[user:barzi]], [[user:drix]], [[user:fabien]]
* [[https://hackaday.io/project/163657-hdmi-to-fpga-to-apa102|giant led panel with fpga]] .. interesting RS485 data transmitter for long distances (with board)
===== Ressources =====
* [[https://www.vishay.com/docs/83608/h11aa1.pdf|Optocoupleur/capteur 240V du secteur]]
* [[https://hackspark.fr/fr/electronique/1310-relay-module-solid-state-high-level-8-channel-5v-dc-.html|solid state relayX8]] qui est zerocrossing
===== Dev log =====
==== session 22 fev 2019 ====
{{:projets:fuz:acmatrix_leds_action.jpg?400|}}
{{:projets:fuz:acmatrix_zero_crossing.jpg?400|hint: the code is not working here...(should be waiting for HIGH)}}
{{:projets:fuz:acmatrix_relays.jpg?400|}}
{{:projets:fuz:acmatrix_scanlines.jpg?400|}}
===== Code =====
++++ Code arduino 240V lettres 2 colonnes |
#include
#define DEBUG false
#define COL_NB 2
#define LIN_NB 7
int pin_col[COL_NB] = {3, 2};
int pin_lin[LIN_NB] = {4, 5, 6, 7, 8, 9, 10};
int seg[2][7] = { {0, 1, 0, 1, 0, 0, 0},{1, 0, 1, 0, 1, 0, 0} };
//AC
#define pinACsense A0
int last_AC_detect = LOW;
void setup() {
//AC
pinMode2(pinACsense, INPUT);
pinMode2(LED_BUILTIN, OUTPUT);
for (int i = 0; i < COL_NB; i++) {
pinMode2(pin_col[i], OUTPUT);
}
for (int i = 0; i < LIN_NB; i++) {
pinMode2(pin_lin[i], OUTPUT);
}
if (DEBUG) Serial.begin(115200);
if (DEBUG) Serial.println("let's rock!");
}
int letter[7];
void loop() {
//int digitNb = ((long)millis / 1000) % 2;
// COLONNES < 2
for (int j = 0; j < 2; j++) {
// copy current letter
/*
for (int k = 0; k < 7; k++) {
letter[k] = seg[j][k];
if (DEBUG) Serial.print(letter[k]);
if (DEBUG) Serial.print("\t");
}
if (DEBUG) Serial.println("");
*/
////////////////////
// allume une colonne
int b = pin_col[j];
digitalWrite2(b, HIGH);
// LIGNES < 7
for (int i = 0; i < 7; i++) {
int a = pin_lin[i];
//if (letter[i] == 1) {
if (seg[j][i] == 1) {
digitalWrite2(a, HIGH);
if (DEBUG) Serial.print("HIGH");
}
else {
digitalWrite2(a, LOW);
if (DEBUG) Serial.print("LOW");
}
if (DEBUG) Serial.println("");
} // end lines
// persistence retinienne (env 40ms)
delayMicroseconds(9000);
// Wait for AC sync...
int AC_detect = LOW;
while ( AC_detect != HIGH) {
AC_detect = digitalRead2(pinACsense);
}
// cols down
digitalWrite2(b, LOW);
// lines down
for (int t = 0; t < 7; t++) {
int z = pin_lin[t];
digitalWrite2(z, LOW);
}
} // end cols
}
++++
++++ Code arduino 240V led matrix test simple |
#define COL_NB 2
#define LIN_NB 7
int pin_col[COL_NB] = {2, 3};
int pin_lin[LIN_NB] = {4, 5, 6, 7, 8, 9, 10};
void setup() {
for (int i = 0; i < COL_NB; i++) {
pinMode(pin_col[i], OUTPUT);
}
for (int i = 0; i < LIN_NB; i++) {
pinMode(pin_lin[i], OUTPUT);
}
Serial.begin(114200);
Serial.println("let's rock!");
}
void loop() {
for (int i = 0; i < 2; i++) {
int a = random(2) + 2;
//int a=pin_col[i];
digitalWrite(a, HIGH);
Serial.print("col= ");
Serial.println(a);
for (int j = 0; j < LIN_NB; j++) {
int b = random(7) + 4;
//int a=pin_lin[j];
digitalWrite(b, HIGH);
Serial.print("line= ");
Serial.println(pin_lin[j]);
delay(50);
random(5)==0?digitalWrite(b, LOW):digitalWrite(b, HIGH);
}
digitalWrite(a, LOW);
/*
for (int j = 0; j < LIN_NB; j++) {
//digitalWrite(pin_lin[j], HIGH);
Serial.print("line= ");
Serial.println(pin_lin[j]);
delay(10);
digitalWrite(pin_lin[j], LOW);
}
digitalWrite(pin_col[i], LOW);
*/
}
}
++++
++++ Code arduino 240V led matrix with AC sensing and FastIO |
#include
#define COL_NB 2
#define LIN_NB 7
int pin_col[COL_NB] = {2, 3};
int pin_lin[LIN_NB] = {4, 5, 6, 7, 8, 9, 10};
//AC
#define pinACsense A0
int last_AC_detect = LOW;
void setup() {
//AC
pinMode2(pinACsense, INPUT);
pinMode2(LED_BUILTIN, OUTPUT);
for (int i = 0; i < COL_NB; i++) {
pinMode2(pin_col[i], OUTPUT);
}
for (int i = 0; i < LIN_NB; i++) {
pinMode2(pin_lin[i], OUTPUT);
}
//Serial.begin(114200);
//Serial.println("let's rock!");
}
int intensity_time = 0;
int step = 40;
// bool back_from_last_scan = false;
void loop() {
// LIGNES < 7
for (int i = 0; i < 4; i++) {
/*
int AC_detect = LOW;
// Wait for AC sync...
while ( AC_detect != HIGH || back_from_last_scan) {
AC_detect = digitalRead(pinACsense);
}
*/
int a = pin_lin[i];
digitalWrite2(a, HIGH);
// COLONNES < 2
for (int j = 0; j < 2; j++) {
int b = pin_col[j];
digitalWrite2(b, HIGH);
}
int AC_detect = LOW;
// Wait for AC sync...
while ( AC_detect != HIGH) {
AC_detect = digitalRead2(pinACsense);
}
//delayMicroseconds(9000);
/*
delayMicroseconds(intensity_time);
intensity_time += step;
if(abs(intensity_time) > 9000) step=-step;
*/
// ligne down
digitalWrite2(a, LOW);
// cols down
for (int j = 0; j < 2; j++) {
int b = pin_col[j];
digitalWrite2(b, LOW);
}
// back_from_last_scan = true;
}
}
++++
===== Roadmap =====
- trouver le principe
- sourcer les compos
- faire la matrice
- faire la commande
- faire le programme
- assembler le tout !
===== Follow-up =====
* Project created on **Fri 15-02-19** by **[[mailto:barzi@jack.tf|barzi]]**