currently I'm still relatively new to Arduino and c++ and am working around with several different scenarios to help me improve in c++
I'm trying to get a servo to turn 0, LED turn on from an if statement, servo turn again to 180 from an if statement, turn LED off from an if statement, servo turn back to 0. essentially a endless loop.
however I'm getting error message "no match for the operator, operand types are 'Servo' and 'int' ".
in the lines " if(myServo =180);{ " and " if(myServo =0);{ ".
which led me to believe that it was an issue with the naming, I "myServo" to "Servo" but no difference.
the full code is below for reference.
any help would be greatly appreciated.
Issue 2:
If you are expecting myServo to return the position of the servo then you are mistaken. Save the servo position to a variable when you write it and use that variable in the test or use myServo.read()
hello world.
as I'm recently new to Arduino coding I'm trying out several scenarios to get a undertsandinng of it.
what I would like to do is make a led turn on, servo turn from that, light turn off from that, servo turn again from that , and loop.
however in code I'm getting errors with "if(myServo =180);{"
saying 'exit status 1, no match for operator=, operand types are Ser and int'
my guess is that ive screwed up somewhere in the naming of it, however it still seems to elude me.
the full code is down below.
many thanks for any responses.
If you are trying to read the position of your servo using
if(myServo =180);
then you are doing it wrong. You set the position of the servo so should know where it is. Save the value previously written to the servo and compare that or use the servo.read() function to determine where the servo was last commanded to go to.
And, as has been pointed out, use == for comparison not =
Please read the first post in any forum entitled how to use this forum. http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.