Hi All!
I'm following along a tutorial via learn.inventr.io, Lesson #9, and I can't figure out either what I'm not following correctly or what they have incorrectly shown me, and how to fix it.
I'm using an Arduino Uno.
Upon verifying the error reads:
"compilation error: 'subtract_button' was not declared in this scope"
Below the first dotted lines is the whole error message. Below that, after the next dotted lines, is the whole code:
/private/var/folders/mq/fqk5rd197k13n_48_czjdqb80000gn/T/.arduinoIDE-unsaved202485-2681-5f190b.nzuuq/sketch_sep5a/sketch_sep5a.ino: In function 'void loop()':
/private/var/folders/mq/fqk5rd197k13n_48_czjdqb80000gn/T/.arduinoIDE-unsaved202485-2681-5f190b.nzuuq/sketch_sep5a/sketch_sep5a.ino:31:33: error: 'subtract_button' was not declared in this scope
ButtonIsPressed = digitalRead(subtract_button);
^~~~~~~~~~~~~~~
/private/var/folders/mq/fqk5rd197k13n_48_czjdqb80000gn/T/.arduinoIDE-unsaved202485-2681-5f190b.nzuuq/sketch_sep5a/sketch_sep5a.ino:31:33: note: suggested alternative: 'subract_button'
ButtonIsPressed = digitalRead(subtract_button);
^~~~~~~~~~~~~~~
subract_button
/private/var/folders/mq/fqk5rd197k13n_48_czjdqb80000gn/T/.arduinoIDE-unsaved202485-2681-5f190b.nzuuq/sketch_sep5a/sketch_sep5a.ino: In function 'void addButtonPressed()':
/private/var/folders/mq/fqk5rd197k13n_48_czjdqb80000gn/T/.arduinoIDE-unsaved202485-2681-5f190b.nzuuq/sketch_sep5a/sketch_sep5a.ino:49:10: error: 'OurSixBitNumber' was not declared in this scope
if(OurSixBitNumber[LED_Selector] == 1)
^~~~~~~~~~~~~~~
/private/var/folders/mq/fqk5rd197k13n_48_czjdqb80000gn/T/.arduinoIDE-unsaved202485-2681-5f190b.nzuuq/sketch_sep5a/sketch_sep5a.ino:49:10: note: suggested alternative: 'OutSixBitNumber'
if(OurSixBitNumber[LED_Selector] == 1)
^~~~~~~~~~~~~~~
OutSixBitNumber
/private/var/folders/mq/fqk5rd197k13n_48_czjdqb80000gn/T/.arduinoIDE-unsaved202485-2681-5f190b.nzuuq/sketch_sep5a/sketch_sep5a.ino: In function 'void subButtonPressed()':
/private/var/folders/mq/fqk5rd197k13n_48_czjdqb80000gn/T/.arduinoIDE-unsaved202485-2681-5f190b.nzuuq/sketch_sep5a/sketch_sep5a.ino:65:23: error: 'subtract_button' was not declared in this scope
while(digitalRead(subtract_button) == 1) {}
^~~~~~~~~~~~~~~
/private/var/folders/mq/fqk5rd197k13n_48_czjdqb80000gn/T/.arduinoIDE-unsaved202485-2681-5f190b.nzuuq/sketch_sep5a/sketch_sep5a.ino:65:23: note: suggested alternative: 'subract_button'
while(digitalRead(subtract_button) == 1) {}
^~~~~~~~~~~~~~~
subract_button
/private/var/folders/mq/fqk5rd197k13n_48_czjdqb80000gn/T/.arduinoIDE-unsaved202485-2681-5f190b.nzuuq/sketch_sep5a/sketch_sep5a.ino:73:10: error: 'OurSixBitNumber' was not declared in this scope
if(OurSixBitNumber[LED_Selector] == 0)
^~~~~~~~~~~~~~~
/private/var/folders/mq/fqk5rd197k13n_48_czjdqb80000gn/T/.arduinoIDE-unsaved202485-2681-5f190b.nzuuq/sketch_sep5a/sketch_sep5a.ino:73:10: note: suggested alternative: 'OutSixBitNumber'
if(OurSixBitNumber[LED_Selector] == 0)
^~~~~~~~~~~~~~~
OutSixBitNumber
/private/var/folders/mq/fqk5rd197k13n_48_czjdqb80000gn/T/.arduinoIDE-unsaved202485-2681-5f190b.nzuuq/sketch_sep5a/sketch_sep5a.ino:80:9: error: 'OurSixBitNumber_Selector' was not declared in this scope
OurSixBitNumber_Selector] = 0;
^~~~~~~~~~~~~~~~~~~~~~~~
/private/var/folders/mq/fqk5rd197k13n_48_czjdqb80000gn/T/.arduinoIDE-unsaved202485-2681-5f190b.nzuuq/sketch_sep5a/sketch_sep5a.ino:80:9: note: suggested alternative: 'OutSixBitNumber'
OurSixBitNumber_Selector] = 0;
^~~~~~~~~~~~~~~~~~~~~~~~
OutSixBitNumber
/private/var/folders/mq/fqk5rd197k13n_48_czjdqb80000gn/T/.arduinoIDE-unsaved202485-2681-5f190b.nzuuq/sketch_sep5a/sketch_sep5a.ino: In function 'void writeLEDs()':
/private/var/folders/mq/fqk5rd197k13n_48_czjdqb80000gn/T/.arduinoIDE-unsaved202485-2681-5f190b.nzuuq/sketch_sep5a/sketch_sep5a.ino:91:10: error: 'OurSixBitNumber' was not declared in this scope
if(OurSixBitNumber[temp] == 1)
^~~~~~~~~~~~~~~
/private/var/folders/mq/fqk5rd197k13n_48_czjdqb80000gn/T/.arduinoIDE-unsaved202485-2681-5f190b.nzuuq/sketch_sep5a/sketch_sep5a.ino:91:10: note: suggested alternative: 'OutSixBitNumber'
if(OurSixBitNumber[temp] == 1)
^~~~~~~~~~~~~~~
OutSixBitNumber
exit status 1
Compilation error: 'subtract_button' was not declared in this scope
Here is my code:
const int add_button=12,
subract_button=13,
NumberOfBits=6;
int OutSixBitNumber[]={0,0,0,0,0,0}, LED_Selector, ButtonIsPressed;
void setup() {
// put your setup code here, to run once:
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(add_button, INPUT);
pinMode(subract_button, INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
ButtonIsPressed = digitalRead(add_button);
if(ButtonIsPressed == 1) {addButtonPressed();}
delay(100);
ButtonIsPressed = digitalRead(subtract_button);
if(ButtonIsPressed == 1) {subButtonPressed();}
resetSelector();
writeLEDs();
}
void addButtonPressed() {
while(digitalRead(add_button) == 1) {}
delay(100);
resetSelector();
while(LED_Selector >= 0 && ButtonIsPressed != 0)
{
if(OurSixBitNumber[LED_Selector] == 1)
{
OurSixBitNumber[LED_Selector] = 0;
LED_Selector--;
}
else
{
OurSixBitNumber[LED_Selector] = 1;
ButtonIsPressed = 0;
}
}
}
void subButtonPressed() {
while(digitalRead(subtract_button) == 1) {}
delay(100);
resetSelector();
while(LED_Selector >= 0 && ButtonIsPressed != 0)
{
if(OurSixBitNumber[LED_Selector] == 0)
{
OurSixBitNumber[LED_Selector] = 1;
LED_Selector--;
}
else
{
OurSixBitNumber_Selector] = 0;
ButtonIsPressed = 0;
}
}
}
void writeLEDs() {
for(int temp = 0; temp < NumberOfBits; temp++)
{
if(OurSixBitNumber[temp] == 1)
digitalWrite(NumberOfBits - temp + 1, HIGH);
else
digitalWrite(NumberOfBits - temp + 1, LOW);
LED_Selector--;
}
}
void resetSelector() {
LED_Selector = NumberOfBits - 1;
}