I am using an Arduino UNO with two shields stacked;
Ceeed Relay shield V3.0 and
2x16 LCD keyboard display
Display shield works great and relay shield works great individually mounted on the UNO. The two together have conflicts because both shields use pins 4, 5, 6, 7 from the UNO.
How do I separate the two in my code to prevent this?
My code:
int MotorControl = 5; // Digital Arduino Pin used to control the motor
#include <LiquidCrystal.h>
// 60 second count down timer that closes the relay at start and opens at end
int hours = 0; // start hours
int minutes = 10; //start min
int seconds = 10; //start seconds
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
void setup() {
// declare pin 5 to be an output:
pinMode(MotorControl, OUTPUT);
digitalWrite(MotorControl,HIGH); // NO3 and COM3 Connected (the machine is running)
}
void loop() {
lcd.begin(16, 2);
lcd.print("Washing Machine ");
delay(2000); // wait before we start the cycle
while (hours > 0 || minutes > 0 || seconds >= 0) {
lcd.setCursor(4, 2);
(hours < 10) ? lcd.print("0") : NULL;
lcd.print(hours);
lcd.print(":");
(minutes < 10) ? lcd.print("0") : NULL;
lcd.print(minutes);
lcd.print(":");
(seconds < 10) ? lcd.print("0") : NULL;
lcd.print(seconds);
lcd.display();
stepDown();
delay(1000);
}
}
void stepDown() {
if (seconds > 0) {
seconds -= 1;
} else {
if (minutes > 0) {
seconds = 59;
minutes -= 1;
} else {
if (hours > 0) {
seconds = 59;
minutes = 59;
hours -= 1;
} else {
trigger();
}
}
}
}
void trigger() {
lcd.clear(); // clears the screen and buffer
lcd.setCursor(0, 1); // set timer position on lcd for end.
digitalWrite(MotorControl,LOW); // NO3 and COM3 Disconnected (the machine is not running)
lcd.println("PROGRAM FINISHED");
}