dc42:
2.pinMode(i,INPUT);
digitalWrite(i,On);
Simpler to use:pinMode(i, INPUT_PULLUP);
instead.
Cool! I didn't know that you could do that. Good to know.
//set D11 through D16 as OUTPUTS and initialize to logic high
//which turns the relay off...logic low turns the relay on
for(int i = 11; i<17; i++)
{
pinMode(i,OUTPUT);
digitalWrite(i, Off);
}
Better to write the data before setting the pin to be an output, to avoid getting a negative going glitch when using active-low relays://set D11 through D16 as OUTPUTS and initialize to logic high
//which turns the relay off...logic low turns the relay on
for(int i = 11; i<17; i++)
{
digitalWrite(i, RelayOff);
pinMode(i,OUTPUT);
}
I remember from coding on AVR Studio that this was appropriate because you want to initialize the pins to a known state before exposing them by setting the data direction register. However, it wasn't working on the arduino so I posted a question on this forum and received a reply that suggested that pinMode initializes the pins to LOW regardless of the state that they were in prior to calling pinMode. It is under reply #1 on this thread:
Am I still missing something?
- Change:
Serial.println("Add Salt = True")to:
Serial.println(F("Add Salt = True"))and similarly everywhere else you print a string literal. It saves RAM, which is precious on an Arduino.
I have just started noticing the println(F(...)). Is this just an alternative to using PROGMEM....not that I have ever even used it? I could be way off here.