hi
i have build a uno with 2 temp sensos, for controling 2 relays
but i only have code for 1 temp sensor and 1relay.
code #include <LiquidCrystal.h>
int reading = 0;
int sensorPin = A0;
int relay =7;
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
pinMode(relay,OUTPUT);
}
thanks for repply
your right i coud have send the code i tryed to make myself
i just coppyed the lines and made diffrent pins,but coud not make it work
thats why i posted the original code.
ok ill try agen
thanks
It should be easy to convert if you use arrays, something like the following.
There are sometimes advantages to using arrays, but I don't think this is such a case.
The temperature sensors have meaning from where they are located/what they are measuring, so having pin numbers in variables like insideTempPin and outsideTempPin makes more sense to me.
The relays control something. relayPin[0] does not tell me anything about what the relay controls. Names like intakeFanRelayPin and exhaustFanRelayPin do.
You could create array index variables with meaningful names. Then, relayPin[INSIDE] and tempSensorPin[OUTSIDE] convey sufficient information.
But, arrays are not always the answer, when the size of the array is small. Now, if you were trying to deal with 500 LEDs, then arrays are the only way to go.