Hi,
I was writting the code, everything was going well until i got this error message : Exit status 1, Error compiling for board Arduino Nano.
Do you know what can be the problem ?
Below the code (not finished yet, as i'm still checking how to display the numbers with the Max7219+7segments) :
#include "LedControl.h"
LedControl lc = LedControl(4,5,6,4);
// ----- Code for Change State for FC-51
// this constant won't change:
const int PinFC51 = 2; // the pin that the pushbutton is attached to
const int PinButtonPlus1 = 3; // the pin that the pushbutton is attached to
const int PinButtonMinus1 = 4; // the pin that the pushbutton is attached to
const int PinButtonReset = 5; // the pin that the pushbutton is attached to
const int PinLED = 13; // the pin that the LED is attached to
// Variables will change:
int buttonStateFC51 = 0; // current state of the FC51
int lastButtonStateFC51 = 0; // previous state of the FC51
int buttonStatePlus1 = 0; // current state of the button
int lastButtonStatePlus1 = 0; // previous state of the button
int buttonStateMinus1 = 0; // current state of the button
int lastButtonStateMinus1 = 0; // previous state of the button
int buttonStateReset = 0; // current state of the button
int FC51 = 0;
int ButtonPlus1 = 0;
int ButtonMinus1 = 0;
int ButtonReset = 0;
// ----- Code for Max7219 + LEDs
int count = 1000;
void setup()
{
// ----- Code for Change State for FC-51
// initialize the button pin as an input:
pinMode(PinFC51, INPUT);
pinMode(PinButtonPlus1, INPUT);
pinMode(PinButtonMinus1, INPUT);
pinMode(PinButtonReset, INPUT);
// initialize the LED as an output:
pinMode(PinLED, OUTPUT);
// initialize serial communication:
Serial.begin(9600);
// ----- Code for Max7219 + LEDs
lc.shutdown(0,false);
lc.setIntensity(0,5);
lc.clearDisplay(0);
}
void loop() {
// if FC51 changes the state, it does +1
ChangeStateFC51();
if (FC51 == 1) {
Plus1();
Update7segment();
FC51=0;
}
// if PushButtonPlus1 is active, it does +1
PushButtonPlus1();
if (ButtonPlus1 == 1) {
Plus1();
Update7segment();
ButtonPlus1=0;
}
// if PushButtonMinus1 is active, it does -1
PushButtonMinus1();
if (ButtonMinus1 == 1) {
Minus1();
Update7segment();
ButtonMinus1=0;
}
// if PushButtonReset is active, it resets to 0
PushButtonReset();
if (ButtonReset == 1) {
Reset();
Update7segment();
ButtonReset=0;
}
}
void ChangeStateFC51() {
// read the FC51 input pin:
buttonStateFC51 = digitalRead(PinFC51);
// compare the buttonState to its previous state
if (buttonStateFC51 != lastButtonStateFC51) {
// if the state has changed from low to high, increment the counter otherwise don't
if (buttonStateFC51 == HIGH) {
FC51=1;
}
// Delay a little bit to avoid bouncing
delay(50);
}
// save the current state as the last state, for next time through the loop
lastButtonStateFC51 = buttonStateFC51;
}
void PushButtonPlus1() {
// read the pushbutton input pin:
buttonStatePlus1 = digitalRead(PinButtonPlus1);
// compare the buttonState to its previous state
if (buttonStatePlus1 != lastButtonStatePlus1) {
// if the state has changed from low to high, increment the counter otherwise don't
if (buttonStatePlus1 == HIGH) {
ButtonPlus1=1;
}
// Delay a little bit to avoid bouncing
delay(50);
}
// save the current state as the last state, for next time through the loop
lastButtonStatePlus1 = buttonStatePlus1;
}
void PushButtonMinus1() {
// read the pushbutton input pin:
buttonStateMinus1 = digitalRead(PinButtonMinus1);
// compare the buttonState to its previous state
if (buttonStateMinus1 != lastButtonStateMinus1) {
// if the state has changed from low to high, increment the counter otherwise don't
if (buttonStateMinus1 == HIGH) {
ButtonMinus1=1;
}
// Delay a little bit to avoid bouncing
delay(50);
}
// save the current state as the last state, for next time through the loop
lastButtonStateMinus1 = buttonStateMinus1;
}
void PushButtonReset() {
// read the pushbutton input pin:
buttonStateReset = digitalRead(PinButtonReset);
// compare the buttonState to its previous state
if (buttonStateReset = 1) {
ButtonReset=1;
}
// Delay a little bit to avoid bouncing
delay(50);
}
void Plus1()
{
}
void Minus1()
{
}
void Reset()
{
}
void Update7segment() {
// ----- Code for Max7219 + LEDs
String t = String(count++);
lc.setDigit(0,0,(int)(t[0]-'0'),true);
lc.setDigit(0,1,(int)(t[1]-'0'),false);
lc.setDigit(0,2,(int)(t[2]-'0'),false);
lc.setDigit(0,3,(int)(t[3]-'0'),false);
delay(100);
lc.shutdown(0,true);
lc.shutdown(0,false);
}
PS : If you find already something wrong in the code (not linked to this issue), you can already let me know