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 Num_Mode = 20
if (Num_Mode >=1 && Num_Mode <=100) {
int modeNum = MAX_POT_VAL/analogRead(potPin)
int mog =
}
Serial.print("Analog Reading: ");
Serial.print(analogRead(potPin));
Serial.print(" is equal to Mode: ");
Serial.println(modeNum);
if (modeNum == 0) {
turnOnLeds();
delay (200);
turnOffLeds();
delay (200);
}
if (modeNum == 1) {
blink(100, 100, 1);
}
if (modeNum == 2) {
blink2(200, 200, 1);
}
}
}
bool inDeadband() {
if (analogRead(potPin) >= 324 && analogRead(potPin) <= 358) {
return true;
}
if (analogRead(potPin) >= 665 && analogRead(potPin) <= 699) {
return true;
}
else {
return false;
}
/*
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.
*/
}
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);
}
void blink(int onTime, int offTime, int repeatCount)
{
int count;
int ledNumber;
for(count = 1; count <= repeatCount; count++)
{
for(ledNumber = 2; ledNumber <= 8; ledNumber++)
{
digitalWrite(ledNumber, HIGH);
digitalWrite(ledNumber + 7, HIGH);
delay(onTime);
digitalWrite(ledNumber, LOW);
digitalWrite(ledNumber + 7, LOW);
delay(offTime);
}
}
}
void blink2(int onTime, int offTime, int repeatCount)
{
int count;
int ledNumber;
for(count = 1; count <= repeatCount; count++)
{
for(ledNumber = 2; ledNumber <= 2; ledNumber++)
{
digitalWrite(ledNumber, HIGH);
digitalWrite(ledNumber + 2, HIGH);
digitalWrite(ledNumber + 4, HIGH);
digitalWrite(ledNumber + 6, HIGH);
delay(onTime);
digitalWrite(ledNumber, LOW);
digitalWrite(ledNumber + 2, LOW);
digitalWrite(ledNumber + 4, LOW);
digitalWrite(ledNumber + 6, LOW);
delay(offTime);
}
}
}