its me, but im here because im stumped
i got an extension to my projet, turns out 1/6 students finishing doest look good, so yea, but im actually wondering how to fix or define certain functions, cause i ran this on a arduino simulator, and no luck
any pointers or ideas, if so, whats wrong with it?
i should mention this code gives no errors, so nothing is giving me a negative
#define DEBUG
const byte numInputs = 4;
const byte inputPins[numInputs] = {2, 3, 4, 5};
const byte numSteps = 7;
const byte steps[numSteps] = {0, 4, 3, 2, 3, 1, 0};
const byte ledPins[numSteps] = {6, 7, 8, 9, 10, 12, 13};
const byte lockPin = A0;
bool lastInputState[] = {HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH} ;
int currentStep = 0;
unsigned long lastDebounceTime = 0;
unsigned long debounceDelay = 50;
void setup() {
for(int i=0; i< numInputs; i++) {
pinMode(inputPins[i], INPUT_PULLUP);
}
for(int i=0; i< numSteps; i++) {
pinMode(ledPins[i], OUTPUT);
}
pinMode(lockPin, OUTPUT);
digitalWrite(lockPin, HIGH);
#ifdef DEBUG
Serial.begin(9600);
Serial.println("Serial Communication Started");
#endif
}
void loop() {
if ( (millis() - lastDebounceTime > debounceDelay)) {
for(int i=0; 1<numInputs; i++) {
int currentInputState = digitalRead(inputPins[i]);
if(currentInputState != lastInputState[i]) {
lastDebounceTime = millis();
}
if(currentInputState == LOW && lastInputState == HIGH) {
if(steps[currentStep] == i) {
currentStep++;
#ifdef DEBUG
Serial.print(F("Nice, Onto the next step #"));
Serial.println(currentStep);
#endif
}
else {
currentStep = 0;
Serial.println("Not Right! Start From Scratch");
}
}
lastInputState[i] = currentInputState;
}
}
if(currentStep == numSteps) {
onSolved();
}
for(int i=0; i<numSteps; i++) {
digitalWrite(ledPins[i], (i < currentStep ? HIGH : LOW));
}
}
void onSolved() {
digitalWrite(lockPin, LOW);
while(true){
for(int i=0; i<numSteps; i++){
digitalWrite(ledPins[i], HIGH);
delay(100);
}
delay(100);
for(int i=0; i<numSteps; i++){
digitalWrite(ledPins[i], HIGH);
delay(100);
}
}
}