Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //this code doesn't work properly.
- #include "LedControl.h" // need the library
- LedControl lc=LedControl(8,10,9,1); //LedControl(int dataPin, int clkPin, int csPin, int numDevices=1);
- int pushButton = 2;
- int val = 0;
- void setup()
- {
- // Add serial for debug
- Serial.begin(9600);
- // the zero refers to the MAX7219 number, it is zero for 1 chip
- lc.shutdown(0,false);// turn off power saving, enables display
- lc.setIntensity(0,8);// sets brightness (0~15 possible values)
- lc.clearDisplay(0);// clear screen
- //Add input button
- pinMode(pushButton, INPUT);
- }
- void loop(){
- if(digitalRead(pushButton) == HIGH){
- lc.shutdown(0,false);
- for (int row=0; row<8; row++)
- {
- for (int col=0; col<8; col++)
- {
- lc.setLed(0,col,row,true); // turns on LED at col, row
- delay(10);
- }
- }
- for (int row=0; row<8; row++)
- {
- for (int col=0; col<8; col++)
- {
- lc.setLed(0,col,row,false); // turns off LED at col, row
- delay(10);
- }
- }
- }else{
- lc.shutdown(0,true);
- Serial.println(digitalRead(pushButton));
- delay(200);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment