Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- byte A[]
- {
- B01110,
- B10001,
- B11111,
- B10001,
- B10001,
- };
- const int Base[]={3,4,5,6,7};
- const int Plus[]={13,12,11,10,9};
- int incomingByte=1;
- void setup() {
- for(int i; i<8; i++)
- {
- pinMode(Base[i],OUTPUT);
- pinMode(Plus[i],OUTPUT);
- digitalWrite(Plus[i],HIGH);
- }
- }
- void loop() {
- if(incomingByte==1)
- {
- show(A,1000);
- }
- }
- void show(byte*image, unsigned long duration)
- {
- unsigned long start=millis(); //begin timing animation
- while(start+duration>millis()) //loop until the duration period has passed
- {
- for(int row=0;row<5;row++)
- {
- digitalWrite(Plus[row], HIGH); //connect row to 5V
- for(int column=0;column<5;column++)
- {
- boolean pixel=bitRead(image[column],row);
- if(pixel==1)
- {
- digitalWrite(Base[column],HIGH); //connect column to GND
- }
- delayMicroseconds(300); //delay for each LED
- digitalWrite(Base[column],LOW); //disconect columnt from GND
- }
- digitalWrite(Plus[row],LOW); //disconnect LEDs
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement