Heliobb

8bits display doesn't work like I want

Aug 6th, 2014
320
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.08 KB | None | 0 0
  1. //this code doesn't work properly.
  2. #include "LedControl.h" //  need the library
  3. LedControl lc=LedControl(8,10,9,1); //LedControl(int dataPin, int clkPin, int csPin, int numDevices=1);
  4. int pushButton = 2;
  5. int val = 0;
  6.  
  7. void setup()
  8. {
  9.   // Add serial for debug
  10.   Serial.begin(9600);
  11.   // the zero refers to the MAX7219 number, it is zero for 1 chip
  12.   lc.shutdown(0,false);// turn off power saving, enables display
  13.   lc.setIntensity(0,8);// sets brightness (0~15 possible values)
  14.   lc.clearDisplay(0);// clear screen
  15.   //Add input button
  16.   pinMode(pushButton, INPUT);
  17. }
  18. void loop(){
  19. if(digitalRead(pushButton) == HIGH){
  20.   lc.shutdown(0,false);
  21.   for (int row=0; row<8; row++)
  22.   {
  23.     for (int col=0; col<8; col++)
  24.     {
  25.       lc.setLed(0,col,row,true); // turns on LED at col, row
  26.       delay(10);
  27.     }
  28.   }
  29.  
  30.   for (int row=0; row<8; row++)
  31.   {
  32.     for (int col=0; col<8; col++)
  33.     {
  34.       lc.setLed(0,col,row,false); // turns off LED at col, row
  35.       delay(10);
  36.     }
  37.   }
  38.  }else{
  39.    lc.shutdown(0,true);
  40.    Serial.println(digitalRead(pushButton));
  41.    delay(200);
  42.  }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment