From this description of "int":
"Syntax
int var = val;
-var - your int variable name
-val - the value you assign to that variable"
I understand that writing
const int pin11 = 11;
pin11 is a variable and its name, 11 is its value.
Just as in int a = 250;
a is the variable and its value is 250.
If i write
const int pin11 = 11;
int a = 250;
void setup(){
pinMode(pin11, OUTPUT);
pinMode(a, OUTPUT);
}
void loop(){
digitalWrite(pin11, HIGH);
digitalWrite(a, HIGH);
}
I know the physical pin 11 on my Arduino UNO will be digital high at 5 volts.
I would assume the code will try to program 'imaginary pin' 250 to turn digitally high also.
But, are the #'s 1-13 and A0-A5 just automatically routed as the physical outputs do to the compiler
when using the pinMode function?
I would much rather prefer using another name for the physical outputs than just a number, which seems confusing.
I want to understand better whats going on with the "pinMode" function.
Here is my beginner knowledge at work trying to make use of my blue board to auto cycle through as an 8 channel switch>
(it compiles fine and is presumed to work)
/* This program will be used to create an on/off
scan of the outputs for an arpeggiator of 8 notes.
The output pins will control the base of a mosfet as a switch
for audio or control a switching ic. It may even be used to
switch between eight variable resistors using BJT transistors
as the switch to ground for a smaller voltage controlled arpeggiated synth. */
// define Atmega328 pins to be used as a constant,nonchangable value.
// Initialize's pins 5-12 on the chip to be used and names them (pin5,pin6,pin7...)
const int pin5 = 5;
const int pin6 = 6;
const int pin7 = 7;
const int pin8 = 8;
const int pin9 = 9;
const int pin10 = 10;
const int pin11 = 11;
const int pin12 = 12;
// Initalizes 'a' as a value to be easily changed in the future.
// Future code: Write 'a' value to a potentiometer value being read,
// Or even read a digital on or off for in tempo scanning
int a = 250; // a = 250 milliseconds when used in the 'delay' function.
// Setup routine runs once the reset button is pushed or when power is applied.
void setup()
{
//make each of the pins an output.
pinMode(pin5, OUTPUT);
pinMode(pin6, OUTPUT);
pinMode(pin7, OUTPUT);
pinMode(pin8, OUTPUT);
pinMode(pin9, OUTPUT);
pinMode(pin10, OUTPUT);
pinMode(pin11, OUTPUT);
pinMode(pin12, OUTPUT);
}
// loop function loops the program forever.
void loop()
{
digitalWrite(pin5, HIGH); //turns the first note on/pin5 high
delay(a); //wait for .25 seconds/plays note for 250 milliseconds
digitalWrite(pin5, LOW); //turns pin 5 off/digital low/zero volts
digitalWrite(pin6, HIGH);
delay(a);
digitalWrite(pin6, LOW);
digitalWrite(pin7, HIGH);
delay(a);
digitalWrite(pin7, LOW);
digitalWrite(pin8, HIGH);
delay(a);
digitalWrite(pin8, LOW);
digitalWrite(pin9, HIGH);
delay(a);
digitalWrite(pin9, LOW);
digitalWrite(pin10, HIGH);
delay(a);
digitalWrite(pin10, LOW);
digitalWrite(pin11, HIGH);
delay(a);
digitalWrite(pin11, LOW);
digitalWrite(pin12, HIGH);
delay(a);
digitalWrite(pin12, LOW);
}