Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. #include "LedControl.h"
  2. LedControl lc=LedControl(12,11,10,1);
  3.  
  4. const uint64_t fpsSHOW[] = {
  5. 0xffffffffffffffff,
  6. 0x0000000000000000
  7. };
  8. void displayImage(uint64_t image) {
  9. for (int i = 0; i < 8; i++) {
  10. byte row = (image >> i * 8)& 0xFF;
  11. for (int j = 0; j < 8; j++) {
  12. lc.setLed(0, i, j, bitRead(row, j));
  13. }
  14. }
  15. // lc.setRow(0,2,B00001111);
  16. }
  17. unsigned long interval[100];
  18. bool whichImg;
  19. unsigned long prevtime = 0;
  20.  
  21. void setup() {
  22. // put your setup code here, to run once:
  23. lc.shutdown(0,false);
  24. /* Set the brightness to a medium values */
  25. lc.setIntensity(0,8);
  26. /* and clear the display */
  27. lc.clearDisplay(0);
  28. whichImg = true;
  29. for(int i = 0; i< 100; i++)
  30. {
  31. interval[i] = long(1000/(float(i)*2.0));
  32. }
  33. }
  34.  
  35.  
  36. void loop() {
  37. unsigned long currenttime = millis();
  38. unsigned long diff = currenttime - prevtime;
  39. if(diff > interval[60]){
  40. prevtime = currenttime;
  41. whichImg = !whichImg;
  42. // displayImage(fpsSHOW[whichImg]);
  43. if(whichImg)
  44. {
  45. for(int i = 0; i < 8; i++){
  46. lc.setRow(0,i,B11111111);
  47. }
  48. }else{
  49. for(int i = 0; i < 8; i++){
  50. lc.setRow(0,i,B00000000);
  51. }
  52. }
  53. }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement