Advertisement
Guest User

Untitled

a guest
Jun 20th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. byte A[]
  2. {
  3. B01110,
  4. B10001,
  5. B11111,
  6. B10001,
  7. B10001,
  8. };
  9.  
  10. const int Base[]={3,4,5,6,7};
  11. const int Plus[]={13,12,11,10,9};
  12. int incomingByte=1;
  13.  
  14. void setup() {
  15. for(int i; i<8; i++)
  16. {
  17. pinMode(Base[i],OUTPUT);
  18. pinMode(Plus[i],OUTPUT);
  19. digitalWrite(Plus[i],HIGH);
  20. }
  21. }
  22.  
  23. void loop() {
  24. if(incomingByte==1)
  25. {
  26. show(A,1000);
  27.  
  28. }
  29. }
  30.  
  31. void show(byte*image, unsigned long duration)
  32. {
  33. unsigned long start=millis(); //begin timing animation
  34. while(start+duration>millis()) //loop until the duration period has passed
  35. {
  36. for(int row=0;row<5;row++)
  37. {
  38. digitalWrite(Plus[row], HIGH); //connect row to 5V
  39. for(int column=0;column<5;column++)
  40. {
  41. boolean pixel=bitRead(image[column],row);
  42. if(pixel==1)
  43. {
  44. digitalWrite(Base[column],HIGH); //connect column to GND
  45. }
  46. delayMicroseconds(300); //delay for each LED
  47. digitalWrite(Base[column],LOW); //disconect columnt from GND
  48. }
  49. digitalWrite(Plus[row],LOW); //disconnect LEDs
  50. }
  51. }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement