From 451728199cd6cd0cdeb4beed5b66d1f272b677f6 Mon Sep 17 00:00:00 2001 From: Stefan Ostermann Date: Thu, 3 Jun 2021 23:05:40 +0200 Subject: [PATCH] First commit --- src/main.cpp | 137 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 137 insertions(+) create mode 100644 src/main.cpp diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..86aa558 --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,137 @@ +#include +#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); +} \ No newline at end of file