Hello!!!
Sorry, another question!
In this program:
=========================================
#include <Servo.h>
int button1 = 0; //button pin, connect to ground to move servo
int press0 = 0;
int button2 = 1; //button pin, connect to ground to move servo
int press1 = 0;
int button3 = 2; //button pin, connect to ground to move servo
int press2 = 0;
int button4 = 3; //button pin, connect to ground to move servo
int press3 = 0;
Servo servoFL,servoFR,servoBL,servoBR;
void setup()
{
pinMode(button0, INPUT);
pinMode(button1, INPUT);
pinMode(button2, INPUT);
pinMode(button3, INPUT);
servoFL.attach(6);
servoFR.attach(7);
servoBL.attach(8);
servoBR.attach(9);
digitalWrite(0, HIGH); //enable pullups to make pin high
digitalWrite(1, HIGH); //enable pullups to make pin high
digitalWrite(2, HIGH); //enable pullups to make pin high
digitalWrite(3, HIGH); //enable pullups to make pin high
}
void loop()
{
press0 = digitalRead(button0);
if (press0 == LOW)
{
servoFL.write(0);
servoFR.write(0);
servoBL.write(0);
servoBR.write(0);
}
press1 = digitalRead(button1);
if (press1 == LOW)
{
servoFL.write(135);
servoFR.write(45);
servoBL.write(45);
servoBR.write(135);
}
press2 = digitalRead(button2);
if (press2 == LOW)
{
servoFL.write(162);
servoFR.write(135);
servoBL.write(18);
servoBR.write(45);
}
press3 = digitalRead(button3);
if (press3 == LOW)
{
servoFL.write(45);
servoFR.write(18);
servoBL.write(135);
servoBR.write(162);
}
}
================================================================
I want to add a card 4 relay (see the picture) which is also plugged into the same circuit with the servos.
I have two temporary buttons and when they are turned on, according to the angles of servos, a 4 relay switches! How to satisfy the requirement?
summary:
The new temporary buttons:
- button 5 => PIN4
- button 6 => PIN5
4 relays:
- relay 1 => PIN10
- relay 2 => PIN11
- relay 3 => PIN12
- relay 4 => Pin13
The buttons are used independently:
I would like to conditionally relay based servo!
An example, if the servos are oriented:
servoFL.write (135);
servoFR.write (45);
servoBL.write (45);
servoBR.write (135);
and which is based on:
- The button 5 (pin4), relay 1 is on, relay 2, 3, 4 off
- The button 6 (pin5), relay 2 is on, the relay 1, 3, 4 is off
etc.
How to fulfill the condition correctly?
Best regards