Ardumotive Arduino Greek Playground
  • Home
    • About us
    • Contact
    • License
  • Arduino
    • Tutorials
    • Workshop
  • Raspberry Pi
  • DIY 3D Printer
  • News
    • Events >
      • Unboxing & Review
    • Blog
The 1st Arduino Playground in Greece - Open Source Hardware

Arduino LED Bluetooth Matrix Display - 80x8 px

Available Languages
Picture
Picture

Εισαγωγή

Published date: 07/1/2020
Picture
Σε αυτόν τον οδηγό θα σας δείξω πως μπορείτε να φτιάξετε και εσείς το δικό σας LED Matrix Display !
 
​
Δυνατότητες: 
- Ώρα
- Ημέρα
- Ημερομηνία
- Θερμοκρασία και υγρασία
- Κείμενο σε κύλιση 
- Ρυθμιζόμενη Φωτεινότητα 
- Επικοινωνία μέσω Bluetooth
- Αποθήκευση στην μνήμη

Τα υλικά που θα χρειαστούμε :

Σε αυτόν τον οδηγό θα χρειαστείτε :
  • Την PCB πλακέτα μας
  • Arduino Pro Mini (5V-16Mhz)
  • Arduino USB to Serial Converter
  • 10x LED Matrix 8x8 MAX7219 modules
  • DS1307 RTC module
  • Αισθητήρας DHT-22 Temp/Hum 
  • HC-06 or HC-05 Bluetooth module
  • Διακόπτης On/Off 
  • Τροφοδοτικό 5V - 3A
  • Buzzer
  • Βύσμα DC αρσενικό  και θηλυκό 
Picture

Σχηματικό κυκλώματος

Picture
Picture
Παράγγειλε τώρα από το pcbway.com και κέρδισε 10 πλακέτες δωρεάν (ισχύει για τα καινούργια μέλη). Οδηγίες για το πως μπορείτε να πάρετε τη δική σας πλακέτα θα βρείτε στο βίντεο που βρίσκεται στην αρχή.

Επίσης μπορείτε να κάνετε τις δικές σας αλλαγές κάνοντας κλικ εδώ.

led_matrix_gerber_pcb.zip
File Size: 45 kb
File Type: zip
Download File

Κώδικας

Συνδέουμε το TTL to USB module με το programming header όπως φαίνεται στο σχηματικό και περνάμε τον παρακάτω κώδικα.
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
/*  Arduino LED Matrix Display - 10x MAX7219 8x8 display-modules   *
 *  Pixels 80x8 - Digital Clock - Thermometer - Ticker             * 
 *  Dev: Michalis Vasilakis - Date: 19/10/19 - Ver. 2.0            * 
 *  Time, Date, Ticker Text and brightness level can be controlled * 
 *  from bluetooth module and computer-android application         */

//Libraries
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Max72xxPanel.h>
#include <dht.h>
#include <Wire.h>
#include <RTClib.h>
#include <SoftwareSerial.h>
#include <EEPROM.h>

//Constants
SoftwareSerial btSerial(A1, A0); // RX, TX
const int bt_state = A2;
const int photoCell = A3;
dht DHT;
const int DHT22_PIN = 9; // Data pin of DHT 22 (AM2302)
RTC_DS1307 rtc;
char daysOfTheWeek[7][12] = {"Sunday","Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
const int pinCS = 10; // Attach CS to this pin, DIN to MOSI and CLK to SCK (cf http://arduino.cc/en/Reference/SPI )
const int numberOfHorizontalDisplays = 10;
const int numberOfVerticalDisplays = 1;
const int wait = 20; // In milliseconds
const int spacer = 1;
const int width = 5 + spacer; // The font width is 5 pixels
Max72xxPanel matrix = Max72xxPanel(pinCS, numberOfHorizontalDisplays, numberOfVerticalDisplays);
const int buzzer = 7;
//Variables
int chk, length, brLevel, photoCellValue, count=0;
float hum, temp;
String msg;
boolean autoBR=true;
boolean messageCompleted=false;
boolean newMessage=false;
String tickerText = "www.Ardumotive.com - Made in Greece!";
char incomingByte; 
String command;
unsigned long previousMillis = 0;        // will store last time LED was updated
boolean flag=false;
int RES=0;

void setup() {
  //writeStringEEPROM(10,"AAA");
  Serial.begin(9600);
  brLevel = EEPROM.read(0);
  autoBR = EEPROM.read(1);
  tickerText = readStringEEPROM(10);
  
  Serial.println("BR LEVEL: "+String(brLevel));
  Serial.println("AUTO BR: "+String(autoBR));
  Serial.println("TEXT: "+tickerText);
  btSerial.begin(9600);
  rtc.begin();
  //rtc.adjust(DateTime(2017, 03, 21, 19, 47, 0));   // <----------------------SET TIME AND DATE: YYYY,MM,DD,HH,MM,SS
  matrix.setIntensity(1); // Use a value between 0 and 15 for brightness
  // Adjust to your own needs
  delay(100);
 /*
  matrix.setPosition(0, 9, 0); // The first display is at <0, 0>
  matrix.setPosition(1, 8, 0); // The second display is at <1, 0>
  matrix.setPosition(2, 7, 0); // The third display is at <2, 0>
  matrix.setPosition(3, 6, 0); // And the last display is at <3, 0>
  matrix.setPosition(4, 5, 0); // And the last display is at <3, 0>
  matrix.setPosition(5, 4, 0); // And the last display is at <3, 0>
  matrix.setPosition(6, 3, 0); // And the last display is at <3, 0>
  matrix.setPosition(7, 2, 0); // And the last display is at <3, 0>
  matrix.setPosition(8, 1, 0); // And the last display is at <3, 0>
  matrix.setPosition(9, 0, 0); // And the last display is at <3, 0>
*/
}
void(* resetFunc) (void) = 0;
void loop() {
  unsigned long currentMillis = millis();
  communication();
  //Update thermometer and photoCell variables and on starting
  if (count==0){
    chk = DHT.read22(DHT22_PIN);
    delay(20);
    //Read data and store it to variables hum and temp
    hum = DHT.humidity;
    temp= DHT.temperature;
    controlBR();
  }
  //Show content 
  if (currentMillis - previousMillis >= 1000) {
    previousMillis = currentMillis;
    count++; //Seconds
  }
  //First display the clock for 5sec
  if (count>=0 && count <5){
    time();
    flag=false;
  }
  //Then the day of the week for 3sec
  else if (count>=5 && count<7){
    if (!flag){
      today();
      flag=true;
    }
  }
  //Then the date for 3sec
  else if (count>=7 && count<11){
    if (count==7) {flag=false;}
    if (!flag){
      date();
      flag=true;
    }
  }
  //Then the temperature for 3sec
  else if (count>=11 && count<14){
    if (count==11) {flag=false;}
    if (!flag){
      temperature();
      flag=true;
    }
  }
  //Then the humidity for 3sec
  else if (count>=14 && count<17){
    if (count==14) {flag=false;}
    if (!flag){
      humidity();
      flag=true;
    }
  }
  //Finally the ticker text
  else if (count>=17){
    if(tickerText!=""){
      scroll();
      fullOff();
      delay(100);
    }
    //RESET ARDUINO -- THIS WILL FIX SOME DISPLAY PROBLEMS
    if (RES==5){
      matrix.shutdown(true);
      resetFunc();
    }
    RES++;
    count=0; //<----reset
  }
}
//Bluetooth communication
void communication(){
  
  if (btSerial.available()){
    incomingByte = btSerial.read();
    if(incomingByte=='>'){
       messageCompleted=true;
       newMessage=false;
    }
    else if (incomingByte=='<'){
       newMessage=true;
    }

    if (newMessage){
       command.concat(incomingByte);
    }
  }
  
  
  if(messageCompleted){
    //Brightness level
    if (command.charAt(1)=='B'){
      if (command.substring(2)=="Auto"){
        autoBR=true;
      }
      else{
        autoBR=false;
        brLevel= (command.substring(2)).toInt() - 1; 
      }
      EEPROM.write(0, brLevel);
      EEPROM.write(1, autoBR);
      tone(buzzer,800,500);
      controlBR();
    }
    //Update clock
    else if (command.charAt(1)=='T'){
      int h = (command.substring(2,4)).toInt();
      int m = (command.substring(5,7)).toInt();
      int s = (command.substring(8,10)).toInt();
      int D = (command.substring(11,13)).toInt();
      int M = (command.substring(14,16)).toInt();
      int Y = (command.substring(17,21)).toInt();
      rtc.adjust(DateTime(Y,M,D,h,m,s)); // <----------------------SET TIME AND DATE: YYYY,MM,DD,HH,MM,SS
      tone(buzzer,800,500);
    }
    //Update ticker text
    else if (command.charAt(1)=='t'){
      tickerText=command.substring(2);   
      tone(buzzer,800,500);
      writeStringEEPROM(10,tickerText);  
    }
    command="";
    messageCompleted=false;
  }
}
void writeStringEEPROM(char addr,String data)
{
  int _size = data.length();
  int i;
  for (i = 0; i < _size; i++)
  {
    EEPROM.write(addr + i, data[i]);
  }
  EEPROM.write(addr + _size, '\0'); //Add termination null character for String Data
}
String readStringEEPROM(char add)
{
  int i;
  char data[500]; //Max 100 Bytes
  int len=0;
  unsigned char k;
  k=EEPROM.read(add);
  while(k != '\0' && len<500)   //Read until null character
  {    
    k=EEPROM.read(add+len);
    data[len]=k;
    len++;
  }
  data[len]='\0';
  return String(data);
}
//Control brightness - It will run on every complete loop!
void controlBR(){
  if (autoBR){
    photoCellValue = analogRead(photoCell);
    Serial.println(photoCellValue);
    photoCellValue = map(photoCellValue,1023,0,0,15); 
    matrix.setIntensity(photoCellValue); // Use a value between 0 and 15 for brightness
  }
  else{
    matrix.setIntensity(brLevel); // Use a value between 0 and 15 for brightness
  }
}
//Print time
void time(){
   DateTime now = rtc.now();
   int HH = now.hour();
   int MM = now.minute();
   int SS = now.second();
   if (HH<10){
     msg = "0" + String(HH) + ":"; 
   }
   else{
     msg = String(HH) + ":";
   }
   if (MM<10){
     msg += "0" + String(MM) + ":";
   }
   else{
     msg += String(MM) + ":";
   }
   if (SS<10){
     msg += "0" + String(SS);
   }
   else{
     msg += String(SS);
   }
   length = msg.length() * width;
   //fill with blank spaces the rest of the display area
   for (int i = numberOfHorizontalDisplays*8-length; i>0; i--){
     msg += " ";
   }
   matrix.setCursor((numberOfHorizontalDisplays*8-length)/2,0); // Center text 
   matrix.fillScreen(LOW);
   matrix.print(msg);
   matrix.write();
}
//Print day of week
void today(){
  DateTime now = rtc.now();
  //Day of week
  msg = daysOfTheWeek[now.dayOfTheWeek()];
  length = msg.length() * width;
  //fill with blank spaces the rest of the display area
  for (int i = 8; i>0; i--){
    msg += " ";
  }
  matrix.setCursor((numberOfHorizontalDisplays*8-length)/2,0); // Center text 
  matrix.fillScreen(LOW);
  matrix.print(msg);
  matrix.write();
}
//Print date
void date(){
  DateTime now = rtc.now();
  //Date:
  int dd = now.day();
  int mm = now.month();
  int yyyy = now.year();
  if (dd<10){
    msg = "0" + String(dd) + ":"; 
  }
  else{
    msg = String(dd) + ":";
  }
  if (mm<10){
    msg += "0" + String(mm) + ":";
  }
  else{
    msg += String(mm) + ":";
  }
  msg += String(yyyy);
  length = msg.length() * width;
  //fill with blank spaces the rest of the display area
  for (int i = 8; i>0; i--){
    msg += " ";
  }
  matrix.setCursor((numberOfHorizontalDisplays*8-length)/2,0); // Center text 
  matrix.fillScreen(LOW);
  matrix.print(msg);
  matrix.write();
}
//Print temp and humidity
void temperature() {
    msg = "Temp: " + String(temp) +"oC";
    length = msg.length() * width;
    //fill with blank spaces the rest of the display area
    for (int i = 8; i>0; i--){
      msg += " ";
    }
    matrix.setCursor((numberOfHorizontalDisplays*8-length)/2,0); // Center text 
    matrix.fillScreen(LOW);
    matrix.print(msg);
    matrix.write();
}
void humidity(){
    msg = "Hum: " + String(hum) +"%";
    length = msg.length() * width;
    //fill with blank spaces the rest of the display area
    for (int i = 8; i>0; i--){
      msg += " ";
    }
    matrix.setCursor((numberOfHorizontalDisplays*8-length)/2,0); // Center text 
    matrix.fillScreen(LOW);
    matrix.print(msg);
    matrix.write();
}

//Ticker Text
void scroll(){
  for ( int i = 0 ; i < width * tickerText.length() + matrix.width() - 1 - spacer; i++ ) {

    matrix.fillScreen(LOW);

    int letter = i / width;
    int x = (matrix.width() - 1) - i % width;
    int y = (matrix.height() - 8) / 2; // center the text vertically

    while ( x + width - spacer >= 0 && letter >= 0 ) {
      if ( letter < tickerText.length() ) {
        matrix.drawChar(x, y, tickerText[letter], HIGH, LOW, 1);
      }

      letter--;
      x -= width;
    }

    matrix.write(); // Send bitmap to display

    delay(wait);
  }
}
//Control funcs. for display - Call them in void loop to test the LEDs
void fullOn(){
  matrix.fillScreen(HIGH);
  matrix.write();
}
void fullOff(){
  matrix.fillScreen(LOW);
  matrix.write();
}
Κατεβάστε τον κώδικα απ' εδώ και ανοίξτε το αρχείο με το Arduino IDE. Μέσα θα βρείτε όλες τις απαραίτητες βιβλιοθήκες.
led_matrix_display.zip
File Size: 363 kb
File Type: zip
Download File

Gallery

Κουτί

Χρησιμοποιήστε ασπρόμαυρο plexiglass πάχους 3mm:
  • 2τεμ 33x4 cm
  • 2τεμ 33x6 cm
  • 2pτεμ 6.6x4.6 cm (left and right)

Προαιρετικά , αν έχετε 3D εκτυπωτή εκτυπώστε την δεξιά και αριστερή πλευρά.
ledmatrixleft.stl
File Size: 37 kb
File Type: stl
Download File

ledmatrixright.stl
File Size: 141 kb
File Type: stl
Download File

Λογισμικό και πρωτόκολλο επικοινωνίας 

Picture
Από εδώ μπορείτε να κατεβάσετε το λογισμικό για Windows. Σύντομα θα είναι διαθέσιμη και η εφαρμογή για Android.
​
ardumotive_led_matrix__windows_.zip
File Size: 490 kb
File Type: zip
Download File

Μπορείτε να φτιάξετε την δική σας εφαρμογή για οποιοδήποτε λειτουργικό σύστημα, χρησιμοποιώντας το παρακάτω πρωτόκολλο.
Πρωτόκολλο Επικοινωνίας :
  • Για ημερομηνία και ώρα στείλτε: <THH:MM:SS dd/mm/yyyy>
  • Για κύλιση  κειμένου στείλτε: <tYour Text Here>
  • Για το επίπεδο της φωτεινότητας στείλτε: <BAuto> ή <Bvalue> (τιμές από 1 έως 16)

Εφαρμογή για Android συσκευές

Picture
ardumotive_led_display_v3.apk
File Size: 1941 kb
File Type: apk
Download File

Picture

Search Engine

Picture

Licence 

Picture

Help us to grow up!

Picture


Donate us
About us
License
Cookies policy

Visit the biggest Arduino Shop in Greece!

Picture
find us on dwrean.net
find us on Codebender
find us on Instructables
Developed and designed by Vasilakis Michalis Copyright © 2013 Ardumotive All Rights Reserved
All trademarks referenced herein are properties of their
Powered by Create your own unique website with customizable templates.
Design by DivTag Templates
Ardumotive Arduino Greek Playground