Hello, I'm looking for some guidance. I'm making a simple random number generator that outputs to a MAX7219 8x8 matrix LED display. My first test is simply to have it output a number between 1 and 12 every time I press the reset button.
I keep running into this error, despite me checking things over a bunch.
Arduino: 1.8.2 (Windows 10), Board: "Arduino/Genuino Uno"
D:\Documents\Arduino\firstrandomtomatrixtest\firstrandomtomatrixtest.ino: In function 'void setup()':
firstrandomtomatrixtest:38: error: a function-definition is not allowed here before '{' token
void loop () {
^
firstrandomtomatrixtest:106: error: expected '}' at end of input
}
^
exit status 1
a function-definition is not allowed here before '{' token
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
My code is here:
//first test of this random number generator to MAX7219 matrix display
#include "LedControlMS.h"
/*
pin 12 is connected to the DataIn
pin 11 is connected to the CLK
pin 10 is connected to LOAD
*/
#define NBR_MTX 2
LedControl lc = LedControl(12, 11, 10, 4);
long randNumber;
void setup() {
/*
The MAX72XX is in power-saving mode on startup,
we have to do a wakeup call
*/
Serial.begin (9600);
Serial.println("Setup");
//digitCounter=0;
for (int i = 0; i < NBR_MTX; i++) {
lc.shutdown(i, false);
/* Set the brightness to a medium values */
lc.setIntensity(i, 1);
/* and clear the display */
lc.clearDisplay(i);
randomSeed(analogRead(0));
}
//delay(100);
void loop () {
randNumber = random(12);
delay(100);
if (randNumber == 0) {
lc.writeString(0, "1");
delay(5000);
}
if (randNumber == 1) {
lc.writeString(0, "2");
delay(5000);
}
if (randNumber == 2) {
lc.writeString(0, "3");
delay(5000);
}
if (randNumber == 4) {
lc.writeString(0, "5");
delay(5000);
}
if (randNumber == 5) {
lc.writeString(0, "6");
delay(5000);
}
if (randNumber == 6) {
lc.writeString(0, "7");
delay(5000);
}
if (randNumber == 7) {
lc.writeString(0, "8");
delay(5000);
}
if (randNumber == 8) {
lc.writeString(0, "9");
delay(5000);
}
if (randNumber == 9) {
lc.writeString(0, "10");
delay(1000);
lc.writeString(1, "10");
delay(5000);
}
if (randNumber == 10) {
lc.writeString(0, "11");
delay(1000);
lc.writeString(1, "11");
delay(5000);
}
if (randNumber == 11) {
lc.writeString(0, "12");
delay(1000);
lc.writeString(1, "12");
delay(5000);
}
}
}
Any help would be deeply appreciated!