Skip to content

Commit 1c07645

Browse files
authored
Add files via upload
1 parent 15ef54a commit 1c07645

File tree

3 files changed

+375
-0
lines changed

3 files changed

+375
-0
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#include "LedControl.h"
2+
LedControl lc=LedControl(7,6,5,2); // Pins: DIN,CLK,CS, # of Display connected
3+
unsigned long delayTime=200; // Delay between Frames
4+
// Put values in arrays
5+
byte hurufA[] = {0x3C,0x24,0x24,0x7E,0x62,0x62,0x62,0x00};
6+
byte hurufB[] = {0x7C,0x24,0x24,0x3E,0x32,0x32,0x7E,0x00};
7+
byte hurufC[] =
8+
{
9+
B00111110, // First frame of invader #1
10+
B00100010,
11+
B00100000,
12+
B01100000,
13+
B01100000,
14+
B01100010,
15+
B01111110,
16+
B00000000
17+
};
18+
void setup()
19+
{
20+
lc.shutdown(0,false); // Wake up displays
21+
lc.setIntensity(0,1); // Set intensity levels
22+
lc.clearDisplay(0); // Clear Displays
23+
//device ke 2
24+
lc.shutdown(1,false); // Wake up displays
25+
lc.setIntensity(1,1); // Set intensity levels
26+
lc.clearDisplay(1); // Clear Displays
27+
}
28+
29+
// Take values in Arrays and Display them
30+
void A(int dev)
31+
{
32+
for (int i = 0; i < 8; i++)
33+
{
34+
lc.setRow(dev,i,hurufA[i]);
35+
}
36+
}
37+
void B(int dev)
38+
{
39+
for (int i = 0; i < 8; i++)
40+
{
41+
lc.setRow(dev,i,hurufB[i]);
42+
}
43+
}
44+
void C(int dev)
45+
{
46+
for (int i = 0; i < 8; i++)
47+
{
48+
lc.setRow(dev,i,hurufC[i]);
49+
}
50+
}
51+
void loop()
52+
{
53+
// Put #1 frame on both Display
54+
A(0);
55+
delay(1000);
56+
// lc.clearDisplay(0);
57+
A(1);
58+
B(0);
59+
delay(1000);
60+
B(1);
61+
C(0);
62+
delay(1000);
63+
}
Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
#include <LEDMatrixDriver.hpp>
2+
3+
// This sketch draw marquee text on your LED matrix using the hardware SPI driver Library by Bartosz Bielawski.
4+
// Example written 16.06.2017 by Marko Oette, www.oette.info
5+
6+
// Define the ChipSelect pin for the led matrix (Dont use the SS or MISO pin of your Arduino!)
7+
// Other pins are Arduino specific SPI pins (MOSI=DIN, SCK=CLK of the LEDMatrix) see https://www.arduino.cc/en/Reference/SPI
8+
const uint8_t LEDMATRIX_CS_PIN = 9;
9+
10+
// Number of 8x8 segments you are connecting
11+
const int LEDMATRIX_SEGMENTS = 4;
12+
const int LEDMATRIX_WIDTH = LEDMATRIX_SEGMENTS * 8;
13+
14+
// The LEDMatrixDriver class instance
15+
LEDMatrixDriver lmd(LEDMATRIX_SEGMENTS, LEDMATRIX_CS_PIN);
16+
17+
// Marquee text
18+
char text[] = "DHEA";
19+
20+
// Marquee speed (lower nubmers = faster)
21+
const int ANIM_DELAY = 30;
22+
23+
void setup() {
24+
// init the display
25+
lmd.setEnabled(true);
26+
lmd.setIntensity(2); // 0 = low, 10 = high
27+
}
28+
29+
int x=0, y=0; // start top left
30+
31+
// This is the font definition. You can use http://gurgleapps.com/tools/matrix to create your own font or sprites.
32+
// If you like the font feel free to use it. I created it myself and donate it to the public domain.
33+
byte font[95][8] = { {0,0,0,0,0,0,0,0}, // SPACE
34+
{0x10,0x18,0x18,0x18,0x18,0x00,0x18,0x18}, // EXCL
35+
{0x28,0x28,0x08,0x00,0x00,0x00,0x00,0x00}, // QUOT
36+
{0x00,0x0a,0x7f,0x14,0x28,0xfe,0x50,0x00}, // #
37+
{0x10,0x38,0x54,0x70,0x1c,0x54,0x38,0x10}, // $
38+
{0x00,0x60,0x66,0x08,0x10,0x66,0x06,0x00}, // %
39+
{0,0,0,0,0,0,0,0}, // &
40+
{0x00,0x10,0x18,0x18,0x08,0x00,0x00,0x00}, // '
41+
{0x02,0x04,0x08,0x08,0x08,0x08,0x08,0x04}, // (
42+
{0x40,0x20,0x10,0x10,0x10,0x10,0x10,0x20}, // )
43+
{0x00,0x10,0x54,0x38,0x10,0x38,0x54,0x10}, // *
44+
{0x00,0x08,0x08,0x08,0x7f,0x08,0x08,0x08}, // +
45+
{0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x08}, // COMMA
46+
{0x00,0x00,0x00,0x00,0x7e,0x00,0x00,0x00}, // -
47+
{0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x06}, // DOT
48+
{0x00,0x04,0x04,0x08,0x10,0x20,0x40,0x40}, // /
49+
{0x00,0x38,0x44,0x4c,0x54,0x64,0x44,0x38}, // 0
50+
{0x04,0x0c,0x14,0x24,0x04,0x04,0x04,0x04}, // 1
51+
{0x00,0x30,0x48,0x04,0x04,0x38,0x40,0x7c}, // 2
52+
{0x00,0x38,0x04,0x04,0x18,0x04,0x44,0x38}, // 3
53+
{0x00,0x04,0x0c,0x14,0x24,0x7e,0x04,0x04}, // 4
54+
{0x00,0x7c,0x40,0x40,0x78,0x04,0x04,0x38}, // 5
55+
{0x00,0x38,0x40,0x40,0x78,0x44,0x44,0x38}, // 6
56+
{0x00,0x7c,0x04,0x04,0x08,0x08,0x10,0x10}, // 7
57+
{0x00,0x3c,0x44,0x44,0x38,0x44,0x44,0x78}, // 8
58+
{0x00,0x38,0x44,0x44,0x3c,0x04,0x04,0x78}, // 9
59+
{0x00,0x18,0x18,0x00,0x00,0x18,0x18,0x00}, // :
60+
{0x00,0x18,0x18,0x00,0x00,0x18,0x18,0x08}, // ;
61+
{0x00,0x10,0x20,0x40,0x80,0x40,0x20,0x10}, // <
62+
{0x00,0x00,0x7e,0x00,0x00,0xfc,0x00,0x00}, // =
63+
{0x00,0x08,0x04,0x02,0x01,0x02,0x04,0x08}, // >
64+
{0x00,0x38,0x44,0x04,0x08,0x10,0x00,0x10}, // ?
65+
{0x00,0x30,0x48,0xba,0xba,0x84,0x78,0x00}, // @
66+
{0x00,0x1c,0x22,0x42,0x42,0x7e,0x42,0x42}, // A
67+
{0x00,0x78,0x44,0x44,0x78,0x44,0x44,0x7c}, // B
68+
{0x00,0x3c,0x44,0x40,0x40,0x40,0x44,0x7c}, // C
69+
{0x00,0x7c,0x42,0x42,0x42,0x42,0x44,0x78}, // D
70+
{0x00,0x78,0x40,0x40,0x70,0x40,0x40,0x7c}, // E
71+
{0x00,0x7c,0x40,0x40,0x78,0x40,0x40,0x40}, // F
72+
{0x00,0x3c,0x40,0x40,0x5c,0x44,0x44,0x78}, // G
73+
{0x00,0x42,0x42,0x42,0x7e,0x42,0x42,0x42}, // H
74+
{0x00,0x7c,0x10,0x10,0x10,0x10,0x10,0x7e}, // I
75+
{0x00,0x7e,0x02,0x02,0x02,0x02,0x04,0x38}, // J
76+
{0x00,0x44,0x48,0x50,0x60,0x50,0x48,0x44}, // K
77+
{0x00,0x40,0x40,0x40,0x40,0x40,0x40,0x7c}, // L
78+
{0x00,0x82,0xc6,0xaa,0x92,0x82,0x82,0x82}, // M
79+
{0x00,0x42,0x42,0x62,0x52,0x4a,0x46,0x42}, // N
80+
{0x00,0x3c,0x42,0x42,0x42,0x42,0x44,0x38}, // O
81+
{0x00,0x78,0x44,0x44,0x48,0x70,0x40,0x40}, // P
82+
{0x00,0x3c,0x42,0x42,0x52,0x4a,0x44,0x3a}, // Q
83+
{0x00,0x78,0x44,0x44,0x78,0x50,0x48,0x44}, // R
84+
{0x00,0x38,0x40,0x40,0x38,0x04,0x04,0x78}, // S
85+
{0x00,0x7e,0x90,0x10,0x10,0x10,0x10,0x10}, // T
86+
{0x00,0x42,0x42,0x42,0x42,0x42,0x42,0x3e}, // U
87+
{0x00,0x42,0x42,0x42,0x42,0x44,0x28,0x10}, // V
88+
{0x80,0x82,0x82,0x92,0x92,0x92,0x94,0x78}, // W
89+
{0x00,0x42,0x42,0x24,0x18,0x24,0x42,0x42}, // X
90+
{0x00,0x44,0x44,0x28,0x10,0x10,0x10,0x10}, // Y
91+
{0x00,0x7c,0x04,0x08,0x7c,0x20,0x40,0xfe}, // Z
92+
// (the font does not contain any lower case letters. you can add your own.)
93+
}; // {}, //
94+
95+
96+
void loop()
97+
{
98+
// Draw the text to the current position
99+
int len = strlen(text);
100+
drawString(text, len, x, 0);
101+
// In case you wonder why we don't have to call lmd.clear() in every loop: The font has a opaque (black) background...
102+
103+
// Toggle display of the new framebuffer
104+
lmd.display();
105+
106+
// Wait to let the human read the display
107+
delay(ANIM_DELAY);
108+
109+
// Advance to next coordinate
110+
if( --x < len * -8 ) {
111+
x = LEDMATRIX_WIDTH;
112+
}
113+
}
114+
115+
116+
/**
117+
* This function draws a string of the given length to the given position.
118+
*/
119+
void drawString(char* text, int len, int x, int y )
120+
{
121+
for( int idx = 0; idx < len; idx ++ )
122+
{
123+
int c = text[idx] - 32;
124+
125+
// stop if char is outside visible area
126+
if( x + idx * 8 > LEDMATRIX_WIDTH )
127+
return;
128+
129+
// only draw if char is visible
130+
if( 8 + x + idx * 8 > 0 )
131+
drawSprite( font[c], x + idx * 8, y, 8, 8 );
132+
}
133+
}
134+
135+
/**
136+
* This draws a sprite to the given position using the width and height supplied (usually 8x8)
137+
*/
138+
void drawSprite( byte* sprite, int x, int y, int width, int height )
139+
{
140+
// The mask is used to get the column bit from the sprite row
141+
byte mask = B10000000;
142+
143+
for( int iy = 0; iy < height; iy++ )
144+
{
145+
for( int ix = 0; ix < width; ix++ )
146+
{
147+
lmd.setPixel(x + ix, y + iy, (bool)(sprite[iy] & mask ));
148+
149+
// shift the mask by one pixel to the right
150+
mask = mask >> 1;
151+
}
152+
153+
// reset column mask
154+
mask = B10000000;
155+
}
156+
}
Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
#include <LEDMatrixDriver.hpp>
2+
3+
// This sketch draw marquee text on your LED matrix using the hardware SPI driver Library by Bartosz Bielawski.
4+
// Example written 16.06.2017 by Marko Oette, www.oette.info
5+
6+
// Define the ChipSelect pin for the led matrix (Dont use the SS or MISO pin of your Arduino!)
7+
// Other pins are Arduino specific SPI pins (MOSI=DIN, SCK=CLK of the LEDMatrix) see https://www.arduino.cc/en/Reference/SPI
8+
const uint8_t LEDMATRIX_CS_PIN = 9;
9+
10+
// Number of 8x8 segments you are connecting
11+
const int LEDMATRIX_SEGMENTS = 4;
12+
const int LEDMATRIX_WIDTH = LEDMATRIX_SEGMENTS * 8;
13+
14+
// The LEDMatrixDriver class instance
15+
LEDMatrixDriver lmd(LEDMATRIX_SEGMENTS, LEDMATRIX_CS_PIN);
16+
17+
// Marquee text
18+
char text[] = "M IQBAL N";
19+
20+
// Marquee speed (lower nubmers = faster)
21+
const int ANIM_DELAY = 30;
22+
23+
void setup() {
24+
// init the display
25+
lmd.setEnabled(true);
26+
lmd.setIntensity(2); // 0 = low, 10 = high
27+
}
28+
29+
int x=0, y=0; // start top left
30+
31+
// This is the font definition. You can use http://gurgleapps.com/tools/matrix to create your own font or sprites.
32+
// If you like the font feel free to use it. I created it myself and donate it to the public domain.
33+
byte font[95][8] = { {0,0,0,0,0,0,0,0}, // SPACE
34+
{0x10,0x18,0x18,0x18,0x18,0x00,0x18,0x18}, // EXCL
35+
{0x28,0x28,0x08,0x00,0x00,0x00,0x00,0x00}, // QUOT
36+
{0x00,0x0a,0x7f,0x14,0x28,0xfe,0x50,0x00}, // #
37+
{0x10,0x38,0x54,0x70,0x1c,0x54,0x38,0x10}, // $
38+
{0x00,0x60,0x66,0x08,0x10,0x66,0x06,0x00}, // %
39+
{0,0,0,0,0,0,0,0}, // &
40+
{0x00,0x10,0x18,0x18,0x08,0x00,0x00,0x00}, // '
41+
{0x02,0x04,0x08,0x08,0x08,0x08,0x08,0x04}, // (
42+
{0x40,0x20,0x10,0x10,0x10,0x10,0x10,0x20}, // )
43+
{0x00,0x10,0x54,0x38,0x10,0x38,0x54,0x10}, // *
44+
{0x00,0x08,0x08,0x08,0x7f,0x08,0x08,0x08}, // +
45+
{0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x08}, // COMMA
46+
{0x00,0x00,0x00,0x00,0x7e,0x00,0x00,0x00}, // -
47+
{0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x06}, // DOT
48+
{0x00,0x04,0x04,0x08,0x10,0x20,0x40,0x40}, // /
49+
{0x00,0x38,0x44,0x4c,0x54,0x64,0x44,0x38}, // 0
50+
{0x04,0x0c,0x14,0x24,0x04,0x04,0x04,0x04}, // 1
51+
{0x00,0x30,0x48,0x04,0x04,0x38,0x40,0x7c}, // 2
52+
{0x00,0x38,0x04,0x04,0x18,0x04,0x44,0x38}, // 3
53+
{0x00,0x04,0x0c,0x14,0x24,0x7e,0x04,0x04}, // 4
54+
{0x00,0x7c,0x40,0x40,0x78,0x04,0x04,0x38}, // 5
55+
{0x00,0x38,0x40,0x40,0x78,0x44,0x44,0x38}, // 6
56+
{0x00,0x7c,0x04,0x04,0x08,0x08,0x10,0x10}, // 7
57+
{0x00,0x3c,0x44,0x44,0x38,0x44,0x44,0x78}, // 8
58+
{0x00,0x38,0x44,0x44,0x3c,0x04,0x04,0x78}, // 9
59+
{0x00,0x18,0x18,0x00,0x00,0x18,0x18,0x00}, // :
60+
{0x00,0x18,0x18,0x00,0x00,0x18,0x18,0x08}, // ;
61+
{0x00,0x10,0x20,0x40,0x80,0x40,0x20,0x10}, // <
62+
{0x00,0x00,0x7e,0x00,0x00,0xfc,0x00,0x00}, // =
63+
{0x00,0x08,0x04,0x02,0x01,0x02,0x04,0x08}, // >
64+
{0x00,0x38,0x44,0x04,0x08,0x10,0x00,0x10}, // ?
65+
{0x00,0x30,0x48,0xba,0xba,0x84,0x78,0x00}, // @
66+
{0x00,0x1c,0x22,0x42,0x42,0x7e,0x42,0x42}, // A
67+
{0x00,0x78,0x44,0x44,0x78,0x44,0x44,0x7c}, // B
68+
{0x00,0x3c,0x44,0x40,0x40,0x40,0x44,0x7c}, // C
69+
{0x00,0x7c,0x42,0x42,0x42,0x42,0x44,0x78}, // D
70+
{0x00,0x78,0x40,0x40,0x70,0x40,0x40,0x7c}, // E
71+
{0x00,0x7c,0x40,0x40,0x78,0x40,0x40,0x40}, // F
72+
{0x00,0x3c,0x40,0x40,0x5c,0x44,0x44,0x78}, // G
73+
{0x00,0x42,0x42,0x42,0x7e,0x42,0x42,0x42}, // H
74+
{0x00,0x7c,0x10,0x10,0x10,0x10,0x10,0x7e}, // I
75+
{0x00,0x7e,0x02,0x02,0x02,0x02,0x04,0x38}, // J
76+
{0x00,0x44,0x48,0x50,0x60,0x50,0x48,0x44}, // K
77+
{0x00,0x40,0x40,0x40,0x40,0x40,0x40,0x7c}, // L
78+
{0x00,0x82,0xc6,0xaa,0x92,0x82,0x82,0x82}, // M
79+
{0x00,0x42,0x42,0x62,0x52,0x4a,0x46,0x42}, // N
80+
{0x00,0x3c,0x42,0x42,0x42,0x42,0x44,0x38}, // O
81+
{0x00,0x78,0x44,0x44,0x48,0x70,0x40,0x40}, // P
82+
{0x00,0x3c,0x42,0x42,0x52,0x4a,0x44,0x3a}, // Q
83+
{0x00,0x78,0x44,0x44,0x78,0x50,0x48,0x44}, // R
84+
{0x00,0x38,0x40,0x40,0x38,0x04,0x04,0x78}, // S
85+
{0x00,0x7e,0x90,0x10,0x10,0x10,0x10,0x10}, // T
86+
{0x00,0x42,0x42,0x42,0x42,0x42,0x42,0x3e}, // U
87+
{0x00,0x42,0x42,0x42,0x42,0x44,0x28,0x10}, // V
88+
{0x80,0x82,0x82,0x92,0x92,0x92,0x94,0x78}, // W
89+
{0x00,0x42,0x42,0x24,0x18,0x24,0x42,0x42}, // X
90+
{0x00,0x44,0x44,0x28,0x10,0x10,0x10,0x10}, // Y
91+
{0x00,0x7c,0x04,0x08,0x7c,0x20,0x40,0xfe}, // Z
92+
// (the font does not contain any lower case letters. you can add your own.)
93+
}; // {}, //
94+
95+
96+
void loop()
97+
{
98+
// Draw the text to the current position
99+
int len = strlen(text);
100+
drawString(text, len, x, 0);
101+
// In case you wonder why we don't have to call lmd.clear() in every loop: The font has a opaque (black) background...
102+
103+
// Toggle display of the new framebuffer
104+
lmd.display();
105+
106+
// Wait to let the human read the display
107+
delay(ANIM_DELAY);
108+
109+
// Advance to next coordinate
110+
if( --x < len * -8 ) {
111+
x = LEDMATRIX_WIDTH;
112+
}
113+
}
114+
115+
116+
/**
117+
* This function draws a string of the given length to the given position.
118+
*/
119+
void drawString(char* text, int len, int x, int y )
120+
{
121+
for( int idx = 0; idx < len; idx ++ )
122+
{
123+
int c = text[idx] - 32;
124+
125+
// stop if char is outside visible area
126+
if( x + idx * 8 > LEDMATRIX_WIDTH )
127+
return;
128+
129+
// only draw if char is visible
130+
if( 8 + x + idx * 8 > 0 )
131+
drawSprite( font[c], x + idx * 8, y, 8, 8 );
132+
}
133+
}
134+
135+
/**
136+
* This draws a sprite to the given position using the width and height supplied (usually 8x8)
137+
*/
138+
void drawSprite( byte* sprite, int x, int y, int width, int height )
139+
{
140+
// The mask is used to get the column bit from the sprite row
141+
byte mask = B10000000;
142+
143+
for( int iy = 0; iy < height; iy++ )
144+
{
145+
for( int ix = 0; ix < width; ix++ )
146+
{
147+
lmd.setPixel(x + ix, y + iy, (bool)(sprite[iy] & mask ));
148+
149+
// shift the mask by one pixel to the right
150+
mask = mask >> 1;
151+
}
152+
153+
// reset column mask
154+
mask = B10000000;
155+
}
156+
}

0 commit comments

Comments
 (0)