I have two Arduinos, two buttons and one servo motor.
I want to control a servo motor with two Arduino's when I pressed the buttons. I linked Arduino PWM pins (first Arduino PWM pin is 9, and second one is 3) to the servo motor signal input.
When I pressed button 1 servo motor moving a few, or pressed button 2. but the signal isn't clear, and servo motor doesn't move correctly that I assigned degree.
What can I do for the solution?
My first Arduino code is here:
#include<Servo.h>
#define Buton 8
Servo myServo;
void setup() {
pinMode(Buton, INPUT);
myServo.attach(3);
}
void loop()
{
if (digitalRead(Buton) == 1)
{
myServo.write(90);
}
else
{
myServo.write(180);
}
}
and second arduino code is:
#include<Servo.h>
#define Buton 8
Servo myServo;
void setup() {
pinMode(Buton, INPUT);
myServo.attach(9);
}
void loop()
{
if (digitalRead(Buton) == 1)
{
myServo.write(90);
}
else
{
myServo.write(180);
}
}