Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an example #22

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions examples/LCDemoMovingArrow/LCDemoMovingArrow.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#include <LedControl.h>

int DIN = 12;
int CS = 11;
int CLK = 10;

byte arrow[8]= {0x18,0x3C,0x5A,0x99,0x18,0x18,0x18,0x24};
byte love[8]= {0x00,0x46,0xB9,0x81,0x42,0x24,0x18,0x00};
byte smile[8]= {0x3C,0x42,0xA5,0x81,0xA5,0x99,0x42,0x3C};

LedControl lc=LedControl(DIN,CLK,CS,4);

void setup()
{
for (int i = 0; i <= 3; i++) {
lc.shutdown(i,false);
lc.setIntensity(i, 3);
lc.clearDisplay(i);
}
}

void loop()
{
// Display moving graphics
// Passing an array of graphics through parameters :)
moving(arrow);
moving(love);
moving(smile);
}

void moving (byte array_date [])
{
printByte_in(array_date, 0);
for (int i = 0; i <= 3; i++)
printByte_zhong(array_date, i);
}

void printByte_in(byte character [], int addr)
{
int i = 0, column = 0, value = 0;
for (i = 0; i <= 7; i++) {
value = -1;
for (column = 7 - i; column <= 7; column++) {
value++;
lc.setColumn(addr,column,character[value]);
}
delay(40);
}
}

void printByte_zhong(byte character [], int addr)
{
int sum = 0, value = 0, character_value = 0, range = 0;
int i = 0, j = 0;

for (i = 7, range = 0, value = 1; i >= 0; i--, range++, value++) {
for (j = 7 - range, character_value = 0; j <= 7; j++, character_value++)
lc.setColumn(addr + 1, j, character[character_value]);
for (j = 0; j <= i - 1; j++) {
sum = j + value;
lc.setColumn(addr, j, character[sum]);
}
lc.setColumn(addr, j, 0x00);
lc.setColumn(addr + 1, j, character[sum]);
delay(20);
}
}