Hello! If I follow your questions correctly, you're asking what determines the value you assign to these two (or any) variables?
Here's a way to look at it: an
int (integer) variable you create is just a convenient name that you can use to refer to a whole number later on in your code.
In your code example you are creating a variable named
LEDPin and assigning it a value of
9. That means later on in your code you can have lots of places where you do something like light up the LED with the code:
and then later on, turn it off with
Why do this at all? Well, one reason is you can change your mind about which pin has the LED plugged into it on the microcontroller and you only need to change one piece of code to effectively update it everywhere else. Up at the top of your program, you would change it to:
Code: Select all
int LEDPin = 10; //Pin 10 will be the pin connected to an LED
Now, everywhere in your program that the
LEDPin variable is used will refer to pin
10 instead of pin
9.
Your
myVal variable could be used for something else, maybe the number of seconds to pause between LED blinks. So this isn't a pin number, but instead a timing value where you'd multiply
myVal by 1000 milliseconds in this line:
Hope this helps.