int potPin = A0; // TODO: Replace this value with the pin number associated with the SIG pin on the potentiometer
int NUM_MODES = 3;
int MAX_POT_VAL = 1023; // TODO: Replace this value with the maximum value reading from the potentiometer
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
for (int pinNumber = 2; pinNumber <= 13; pinNumber++) {
pinMode(pinNumber, OUTPUT);
}
}
void loop() {
// put your main code here, to run repeatedly:
turnOffLeds();
if (inDeadband()) {
Serial.print("Analog Reading: ");
Serial.print(analogRead(potPin));
Serial.println(" is in deadband");
blinkStatusLed();
} else {
int modeNum = 0;
//TODO: Replace this with the correct mode number based on the potentiometer reading
Serial.print("Analog Reading: ");
Serial.print(analogRead(potPin));
Serial.print(" is equal to Mode: ");
Serial.println(modeNum);
if (modeNum == 0) {
turnOnLeds();
}
}
}
bool inDeadband() {
/*
In this function you will determine if your potentiometer reading is within a deadband range. You will
be using analogRead as well as if statements.
You should return true if you ARE in deadband and false otherwise.
*/
return false;
}
void turnOffLeds() {
for (int ledNumber = 2; ledNumber <= 13; ledNumber++) {
digitalWrite(ledNumber, LOW);
}
}
void turnOnLeds() {
for (int ledNumber = 2; ledNumber <= 13; ledNumber++) {
digitalWrite(ledNumber, HIGH);
}
}
void blinkStatusLed() {
digitalWrite(13, HIGH);
delay(100);
digitalWrite(13, LOW);
delay(100);
}