Help With "The Most Complete Starter Pack" Tutorial Lesson 5 Code

void setup() {
  pinMode(buttonApin, INPUT_PULLUP);
  pinMode(buttonBpin, INPUT_PULLUP);
  // put your setup code here, to run once:
 

}

void loop()
{
   if (digitalRead(buttonApin) == LOW)
    {
       digitalWrite(ledPin, HIGH);
  }
  if (digitalRead(buttonBpin) == LOW)
  {
    digitalWrite(ledPIn, LOW;
    
  }
  
  // put your main code here, to run repeatedly:

}

I cannot figure out why I keep getting the error message “buttonApin was not declared in this scope”

carterbowman: I cannot figure out why I keep getting the error message "buttonApin was not declared in this scope"

It's because you didn't declare buttonApin. It's like your spretnazzle.

Obviously - you are about to say "Spretnazzle? WTF is spretnazzle?" Well, yes. Exactly. Go back to your tutorial and read the bit about variable declarations.

My tutorial does not mention spretnazzle and I attempted to copy the code given in the tutorial word for word

carterbowman:
My tutorial does not mention spretnazzle

:smiley:

carterbowman:
and I attempted to copy the code given in the tutorial word for word

And you made a mistake. I’m quite sure that there was a little piece of code in the tutorial before the part that starts with void setup().

I do not believe there was anything before the void setup in my tutorial. I am attempting to understand this lesson in the tutorial however any advice would be helpful. I have added this to my code, am I on the right track or do I need to go back to the beginning? #define ledPin

}

#define ledPin
#define buttonApin
#define buttonBpin
void setup() {
 pinMode(buttonApin, (INPUT_PULLUP);
 pinMode(buttonBpin, (INPUT_PULLUP);
 // put your setup code here, to run once:


void loop()
{
  if (digitalRead(buttonApin) == LOW)
   {
      digitalWrite(ledPin, HIGH);
 }
 if (digitalRead(buttonBpin) == LOW)
 {
   digitalWrite(ledPin, LOW);
   
 }
 
 // put your main code here, to run repeatedly:

}

Using #define is a way; not quite like you did it though.

#define ledPin 13
#define buttonApin 2
#define buttonBpin 3

Usually #defines are all capitals (e.g. LEDPIN). As your pin 'names' are not like that, I suspect that the code in the tutorial uses something like

const byte ledPin = 13;
const byte buttonApin = 2;
const byte buttonBpin = 3;

Please be aware that the numbers must match your connections !!

I do not believe there was anything before the void setup in my tutorial.

What's the problem going back to the tutorial and check?

The examples that come with the Arduino IDE actually work, and do not require you to type anything.

I am using the tutorial that came with my kit and this is the link

file:///D:/English%20for%20US%20and%20CA/The%20Most%20Complete%20Starter%20Kit%20for%20UNO.pdf

I did go back into the tutorial and it doesn't mention spretnazzle

jremington: The examples that come with the Arduino IDE actually work, and do not require you to type anything.

I would still have to type it into the sketch correct?

Thanks for everyone's help

NO.

Just as jremington wrote, you do not need to type ANYTHING!

You think that we can read what is on your computer? :D

And nobody mentioned "add to dictionay" as far as I know.

How do I load the code if I am not typing anything? When I started I thought that I just had to load it but I couldn't figure it out so I thought it wanted me to copy it.

Ok I just found the example and can’t believe I missed it. Thanks for the tip

Where can I find the other lessons I should note that I am not using the basic starter kit lessons that are easily visible, is it in a library I missed?

I think that we nee to know what the "The Most Complete Starter Pack" is. Please provide a link. It's not one of the official Arduino kits as far as I can know.

I guess it came with a CD, the examples are probably on there. Copy the example directory to anywhere on your HD; usual location on a Windows system for code that you write is C:\Users\yourusername\Documents\Arduino; nothing wrong with adding a directory in there and copying the example directory from the cd to there.

Sigh. Some people prefer not to think. So much for the socratic method.