First commit
This commit is contained in:
commit
451728199c
|
|
@ -0,0 +1,137 @@
|
|||
#include <Arduino.h>
|
||||
#include "LedControl.h"
|
||||
|
||||
/*
|
||||
|
||||
Now we need a LedControl to work with.
|
||||
***** These pin numbers will probably not work with your hardware *****
|
||||
|
||||
pin 12 is connected to the DataIn
|
||||
|
||||
pin 11 is connected to the CLK
|
||||
|
||||
pin 10 is connected to LOAD
|
||||
|
||||
We have only a single MAX72XX.
|
||||
|
||||
*/
|
||||
|
||||
LedControl lc = LedControl(12, 10, 11, 1);
|
||||
int iteration = 0;
|
||||
|
||||
/* we always wait a bit between updates of the display */
|
||||
|
||||
unsigned long delaytime = 500;
|
||||
|
||||
void setup()
|
||||
{
|
||||
|
||||
/* The MAX72XX is in power-saving mode on startup, we have to do a wakeup call */
|
||||
|
||||
lc.shutdown(0, false);
|
||||
|
||||
/* Set the brightness to a medium values */
|
||||
|
||||
lc.setIntensity(0, 15);
|
||||
|
||||
lc.clearDisplay(0);
|
||||
|
||||
/* and clear the display */
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void printNumber(int v) {
|
||||
int ones;
|
||||
int tens;
|
||||
int hundreds;
|
||||
boolean negative;
|
||||
|
||||
if(v < -999 || v > 999)
|
||||
return;
|
||||
if(v<0) {
|
||||
negative=true;
|
||||
v=v*-1;
|
||||
}
|
||||
ones=v%10;
|
||||
v=v/10;
|
||||
tens=v%10;
|
||||
v=v/10;
|
||||
hundreds=v;
|
||||
if(negative) {
|
||||
//print character '-' in the leftmost column
|
||||
lc.setChar(0,3,'-',false);
|
||||
}
|
||||
else {
|
||||
//print a blank in the sign column
|
||||
lc.setChar(0,3,' ',false);
|
||||
}
|
||||
//Now print the number digit by digit
|
||||
lc.setDigit(0,2,(byte)hundreds,false);
|
||||
lc.setDigit(0,1,(byte)tens,false);
|
||||
lc.setDigit(0,0,(byte)ones,false);
|
||||
}
|
||||
|
||||
void hello()
|
||||
{
|
||||
|
||||
delay(500);
|
||||
lc.setDigit(0,0,0, false);
|
||||
lc.setDigit(0,0,1, false);
|
||||
lc.setDigit(0,0,2, false);
|
||||
lc.setDigit(0,0,3, false);
|
||||
//lc.setLed(0,0,0,true);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
/*
|
||||
lc.setLed(0,0,2,true);
|
||||
lc.setLed(0,0,3,true);
|
||||
lc.setLed(0,0,4,true);
|
||||
lc.setLed(0,0,6,true);
|
||||
lc.setLed(0,0,0,true);
|
||||
*/
|
||||
//delay(2000);
|
||||
/*
|
||||
lc.clearDisplay(0);
|
||||
lc.setLed(0,0,1,true);
|
||||
lc.setLed(0,0,2,true);
|
||||
lc.setLed(0,0,4,true);
|
||||
lc.setLed(0,0,5,true);
|
||||
lc.setLed(0,0,7,true);
|
||||
lc.setLed(0,0,0,true);
|
||||
*/
|
||||
|
||||
//delay(2000);
|
||||
//lc.setLed(0,0,4,true);
|
||||
//lc.setLed(0,0,6,true);
|
||||
//lc.setLed(0,0,iteration%8,true);
|
||||
|
||||
lc.setLed(0,0,1,true);
|
||||
delay(80);
|
||||
lc.clearDisplay(0);
|
||||
lc.setLed(0,0,3,true);
|
||||
delay(80);
|
||||
lc.clearDisplay(0);
|
||||
lc.setLed(0,0,5,true);
|
||||
delay(80);
|
||||
lc.clearDisplay(0);
|
||||
lc.setLed(0,0,7,true);
|
||||
delay(80);
|
||||
lc.clearDisplay(0);
|
||||
lc.setLed(0,0,0,true);
|
||||
delay(80);
|
||||
lc.clearDisplay(0);
|
||||
lc.setLed(0,0,6,true);
|
||||
delay(80);
|
||||
lc.clearDisplay(0);
|
||||
lc.setLed(0,0,4,true);
|
||||
delay(80);
|
||||
lc.clearDisplay(0);
|
||||
lc.setLed(0,0,2,true);
|
||||
iteration++;
|
||||
delay(50);
|
||||
lc.clearDisplay(0);
|
||||
}
|
||||
Loading…
Reference in New Issue