Hi everyone.
I would like ask, as I am completely new to arduino.
I do use 4 relay board to control photo equipment.
I am thinking of adding display shield to be able of controlling relays on and of delays times without connection of my laptop.
So my question is simple. Is it possible at all?
If yes, can someone help me with code?
I do mark delay which I want to control by buttons on display shield with :"<----"
My sketch:
#define PIN_RELAY_1 2 // the Arduino pin, which connects to the IN1 pin of relay module
#define PIN_RELAY_2 3 // the Arduino pin, which connects to the IN2 pin of relay module
#define PIN_RELAY_3 4 // the Arduino pin, which connects to the IN3 pin of relay module
#define PIN_RELAY_4 5 // the Arduino pin, which connects to the IN4 pin of relay module
#define BUTTON_PIN 8
// the setup function runs once when you press reset or power the board
void setup() {
Serial.begin(9600);
// initialize digital pin as an output.
pinMode(PIN_RELAY_1, OUTPUT);
pinMode(PIN_RELAY_2, OUTPUT);
pinMode(PIN_RELAY_3, OUTPUT);
pinMode(PIN_RELAY_4, OUTPUT);
pinMode(BUTTON_PIN, INPUT_PULLUP);
}
// the loop function runs over and over again forever
void loop()
{
byte buttonState = digitalRead(BUTTON_PIN);
if (buttonState == LOW) {
delay(500);
digitalWrite(PIN_RELAY_1, LOW);digitalWrite(PIN_RELAY_4, HIGH);
delay(70); <----
digitalWrite(PIN_RELAY_1, HIGH);
delay(65); <----
digitalWrite(PIN_RELAY_1, LOW);
delay(70); <----
digitalWrite(PIN_RELAY_1, HIGH);
delay(118); <----
digitalWrite(PIN_RELAY_2, HIGH);
delay(100);
digitalWrite(PIN_RELAY_2, LOW); digitalWrite(PIN_RELAY_4, LOW);
delay(100);
}
else {
Serial.println("Button is not pressed");
}}
Many thanks for any help.
Arkadiusz Sibilski