Hello. Today I was wrote a code about control three servos, each servo motor is connected to pins 2, 3 and 4
I need something more advanced maybe put the exact degrees to move an specific servo.
For example: "Welcome to servo motor control system"
First step: Select your servo to be controlled:
1 2 3
Second step: enter numbers degrees you want to move it:
_ (here I put degrees)
My question is: how can I write a Yes or No dialogue? (Using if as conditional sentence)
Some useful functions for you may need
byte ServoNum;
boolean gotServoNum = false;
void setup()
{
Serial.begin(115200);
Serial.println("Enter a Servo number : ");
}
void loop()
{
if (Serial.available() > 0 && gotServoNum == false)
{
ServoNum = Serial.read();
gotServoNum = true;
Serial.print("You chose Servo number ");
Serial.write(ServoNum);
Serial.println();
}
}
1 Like
jim-p
January 8, 2024, 6:41pm
4
Do you mean like this?
if (answer == "YES")
{
//do this
}
else
{
//do that
}
What is the baud rate of the Serial monitor set to ?
It was 115200. Now change it at 9600 and show this repeatdely. This need a wait command
I will try it now. Declare answer as a input
edwinjbg:
This need a wait command
edwinjbg:
Now change it at 9600
If you have the Serial monitor set to 9600 then you are not running the code that I posted
Sorry, I can’t read your screenshots on my phone.
@edwinjbg , please do not cross-post. Other thread removed.
Hi, @edwinjbg
Slow down mate.
Although you are asking 5 different questions here with 5 different threads, it might be better if you concentrate one request at a time, get it solved then go onto the next.
This might help to, please read, you need to post your code in code tags;
https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum
Thanks.. Tom...
system
Closed
July 6, 2024, 9:56pm
20
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.