Hello, I recently bought an Arduino kit for the first time and I wanted to do a project with my friend,
a Carnivorous plant specifically. But sometimes the motor goes a bit then stops then goes to its original position instead of going 120 degrees then staying in that position for 5 seconds and then going back to the original position. Here is the code:
I only tried for the ultrasensor and the values differ when the strange behavior happens for example:
Normally:Distance: 2
2Distance: 48
Strange:Distance: 4
4Distance: 0
I'm a beginner this is my first time using Arduino software so I may not understand every term
The way you've structured your serial debug prints, makes it difficult to troubleshoot. I suggest a more verbose print out. Keep different events on different lines and label everything.
It's a little odd to tell the servo to go to 80 a tenth of a second before you tell it to go to 120. If you use the 'else' feature of the 'if' statement you can avoid jerking the servo.