Again, sorry for my delayed response. Okay, so I read through the latest comments and saw several things that I will address here.
I like to use short variable names so that I don't end up trying to use two slightly different names for one thing.
It's not so much that i'm trying to assign pin values to variables, it's more so I'm trying to rename the pins, so that I don't get confused which pin is which.
DuaneDegn:
You can't just use the pin numbers to figure out if a pin is high or low, you have read the pin. The same goes for setting a pin high.
I thought that was the point of using "digitalRead" and "digitalWrite", otherwise, wouldn't it have a more straight-forward name?
I do plan on doing more sample projects, but I only got this kit shortly before this project, which is the second one and the very first thing we did was set up and "SOS" message with only a single LED.
Grumpy_Mike:
Doing comparisons on PIN numbers is meaningless, you have been told this repeatedly and you keep ignoring it.
Pin name assignments are convoluted and unnecessary. It is not big and clever to do this but stupid.
When doing a project never write all the code and then test. Write a small piece of code, test it, get it working before adding the next little bit. Build up the project from working code.
I'm not quite sure I caught your meaning, but if someone could explain, that would help.
If it is, as you say, stupid to do so, then I must also be stupid. I do not claim to know everything, why else would I ask for help on this?
Thank you for the advice, i'll try to do just that in the future.
Remember, I'm still new to all of this and learning as I go, stumbling and occasionally falling, like a young child learning to walk, but I am at least making an effort to balance myself and take smaller steps as I go. While I do appreciate all of the advice and critique, it feels as if though some of you are simply shouting "You're doing it wrong!" without explaining how I'm wrong. I do hope that you remember that an awful lot of the people coming here may be new to arduino as a whole, and may not understand what you mean when you say something. it would be like speaking in star-trek technobabble to someone who just thawed out of a frozen 70 year nap.
Alright, with that wall of text out of the way, the good stuff. I did get more help from my teacher, managed to get this thing working, which is one of the biggest things I've ever done. So, for those interested, here is the new, fixed, working code:
// Arduino UNO R3 Pin Mapping
// NOTE: Analog input pins A0 through A5 are predefined.
int D0 = 0, D1 = 1, D2 = 2, D3 = 3, D4 = 4, D5 = 5, D6 = 6, D7 = 7, D8 = 8, D9 = 9, D10 = 10, D11 = 11, D12 = 12, D13 = 13, RXPIN = 0, TXPIN = 1;
// NOTE: PWM (Pulse Width Modulation) is available at pins D3, D5, D6, D9, D10, and D11 (in OUTPUT mode only).
// NOTE: SPI programming pins (MISO, MOSI, SCK and SS) are predefined.
/*the section above is part of a template created by my instructor to probably make sure that the students actually look at it.
*/
// INCLUDE statements
// DEFINE statement definitions
// Declare global variables and arrays
// setup block (executed once at the beginning of the program with local scope)
void setup()
{
/*Assigning pin modes to the various pins used in this exercise.*/
pinMode(D2, INPUT);
pinMode(D3, INPUT);
pinMode(D4, INPUT);
pinMode(D5, INPUT);
pinMode(D6, INPUT);
pinMode(D7, INPUT);
pinMode(D8, INPUT);
pinMode(D9, INPUT);
pinMode(A0, OUTPUT);
pinMode(A1, OUTPUT);
pinMode(A2, OUTPUT);
pinMode(A3, OUTPUT);
pinMode(A4, OUTPUT);
}
// loop block (continuously looping block)
void loop()
{
/*Renaming the various pins for the sake of not telling it to do the same thing more than once with the wrong inputs.*/
int H1 = D2, H2 = D3, H3 = D4, H4 = D5, L1 = D6, L2 = D7, L3 = D8, L4 = D9, Pump = A0, F1 = A1, F2 = A2, F3 = A3, F4 = A4;
if (!digitalRead(L1)) {
digitalWrite(Pump, HIGH); digitalWrite(F1, HIGH);
while (!digitalRead(H1)) {}
digitalWrite(Pump, LOW); digitalWrite(F1, LOW);
}
if (!digitalRead(L2)) {
digitalWrite(Pump, HIGH); digitalWrite(F2, HIGH);
while (!digitalRead(H2)) {}
digitalWrite(Pump, LOW); digitalWrite(F2, LOW);
}
if (!digitalRead(L3)) {
digitalWrite(Pump, HIGH); digitalWrite(F3, HIGH);
while (!digitalRead(H3)) {}
digitalWrite(Pump, LOW); digitalWrite(F3, LOW);
}
if (!digitalRead(L4)) {
digitalWrite(Pump, HIGH); digitalWrite(F4, HIGH);
while (!digitalRead(H4)) {}
digitalWrite(Pump, LOW); digitalWrite(F4, LOW);
}
}
// Custom function section