It seems to be working when sensor isn’t connected however when it is connected and detecting object it won’t write powerAngle to what i set as neutral it will make itself go to 91 which isn’t the actual neutral position?
How can I stop this happening? Thanks for the help
Thanks I’ve sort of managed to get it working, however sometimes it will just go out of control and go full forward or reverse, which I’m not sure about, I’ll have to do some more investigation.
Thank you so much, couldn’t have done it without your help
may be form time to time pulseIn() behaves weirdly - may be you want to kinda smooth the variations
one way to do this is keep x% of the previous value and (100-x)% of the new value. for example 80% and 20%long powerPulse = 0.8* powerPulse + 0.2*pulseIn(remoteControlPin, HIGH);
If the pulse is stable, then the value stays the same, but if you get an erroneous pulseIn() read then it will only be worth 20% of the change (if you used 0.2).
The higher the x the slower the reaction to change - so you need to play a bit with x to see what feels right