Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Sergei A. Minayev, 2013
- DIYTJ LED Matrix Module test app
- Working app: http://youtu.be/R10uR81O0YM
- */
- const int aPin = 2;
- const int bPin = 3;
- const int cPin = 4;
- const int dPin = 5;
- const int oePin = 9;
- const int redPin = 8;
- const int greenPin = 7;
- const int strPin = 11;
- const int sckPin = 12;
- int row = 0;
- int count = 0;
- int number, i = 0;
- int dig1, dig2, dig3, dig4 = 0;
- // brutal font, zero element is 0; first element is 1 and so on...
- byte numbers[][16] = {
- {B00000000, B01111110, B01111110, B01100110, B01100110, B01100110, B01100110, B01100110, B01100110, B01100110, B01100110, B01100110, B01100110, B01111110, B01111110, B00000000}, // 0
- {B00000000, B00011000, B00011000, B00011000, B00011000, B00011000, B00011000, B00011000, B00011000, B00011000, B00011000, B00011000, B00011000, B00011000, B00011000, B00000000}, // 1
- {B00000000, B01111110, B01111110, B00000110, B00000110, B00000110, B00000110, B01111110, B01111110, B01100000, B01100000, B01100000, B01100000, B01111110, B01111110, B00000000}, // 2
- {B00000000, B01111110, B01111110, B00000110, B00000110, B00000110, B00000110, B01111110, B01111110, B00000110, B00000110, B00000110, B00000110, B01111110, B01111110, B00000000}, // 3
- {B00000000, B01100110, B01100110, B01100110, B01100110, B01100110, B01100110, B01111110, B01111110, B00000110, B00000110, B00000110, B00000110, B00000110, B00000110, B00000000}, // 4
- {B00000000, B01111110, B01111110, B01100000, B01100000, B01100000, B01100000, B01111110, B01111110, B00000110, B00000110, B00000110, B00000110, B01111110, B01111110, B00000000}, // 5
- {B00000000, B01111110, B01111110, B01100000, B01100000, B01100000, B01100000, B01111110, B01111110, B01100110, B01100110, B01100110, B01100110, B01111110, B01111110, B00000000}, // 6
- {B00000000, B01111110, B01111110, B00000110, B00000110, B00000110, B00000110, B00000110, B00000110, B00000110, B00000110, B00000110, B00000110, B00000110, B00000110, B00000000}, // 7
- {B00000000, B01111110, B01111110, B01100110, B01100110, B01100110, B01100110, B01111110, B01111110, B01100110, B01100110, B01100110, B01100110, B01111110, B01111110, B00000000}, // 8
- {B00000000, B01111110, B01111110, B01100110, B01100110, B01100110, B01100110, B01111110, B01111110, B00000110, B00000110, B00000110, B00000110, B01111110, B01111110, B00000000}, // 9
- };
- void setup() {
- //set pins to output because they are addressed in the main loop
- pinMode(aPin, OUTPUT);
- pinMode(bPin, OUTPUT);
- pinMode(cPin, OUTPUT);
- pinMode(dPin, OUTPUT);
- pinMode(oePin, OUTPUT);
- pinMode(redPin, OUTPUT);
- pinMode(greenPin, OUTPUT);
- pinMode(strPin, OUTPUT);
- pinMode(sckPin, OUTPUT);
- digitalWrite(oePin, LOW);
- }
- void loop() {
- // DIYJT panel code --- start ---
- digitalWrite(oePin, HIGH);
- PORTD = (row << 2) & B00111100;
- digitalWrite(greenPin, HIGH);
- digitalWrite(strPin, LOW);
- shiftOut(redPin, sckPin, MSBFIRST, ~(numbers[dig1][row]));
- shiftOut(redPin, sckPin, MSBFIRST, ~(numbers[dig2][row]));
- shiftOut(redPin, sckPin, MSBFIRST, ~(numbers[dig3][row]));
- shiftOut(redPin, sckPin, MSBFIRST, ~(numbers[dig4][row]));
- digitalWrite(strPin, HIGH);
- digitalWrite(oePin, LOW);
- if (row <= 14) row++; else row = 0;
- // DIYJT panel code --- end ---
- // counter code --- start ---
- if (count<=999) count++; else {
- count = 0;
- if (number<=9999) number++; else number = 0;
- i = number;
- dig1 = i/1000;
- i = i-(dig1*1000);
- dig2 = i/100;
- i = i-(dig2*100);
- dig3 = i/10;
- i = i-(dig3*10);
- dig4 = i;
- }
- // counter code --- end ---
- delayMicroseconds(500);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement