Relatively new to arduino, following paul mcwhorter's tutorials on yt currently on lesson 39 where the goal is to use a joystick to control the direction/speed of the dc motor. Having trouble with the joystick values in the positive x, its resting state is around 370 and its highest is around 770, but whenever i get to that point, it glitches out and is randomly around 500 - 770 which makes it pretty inconsistent. The dc motor also constantly beeps when not in negative. The negative side works pretty well, however have been times when i have to give it a nudge. the wiring diagram below is from paul's website, and the only differences are the joystick pins where i attached 5v and ground to their rails, and the x pin to a0. Any help would be greatly appreciated.
If your joystick is limited to the 370-770 range, you might want to look at this line in your code:
and consider what map does:
If 770 is your top value, try replacing the 1023 with it so when you get to 770 on the joystick, it is putting full power (analogWrite(speedP, 255);) to the motor instead of half with analogWrite(speedP, 128);
OK, but the Abs value -- if it is showing '255' then it should be giving the motor full power and might need less of a kick than at 128.
If by changing the 1023 to 770 you doubled the duty cycle from 128/255 to 255/255 and the motor doesn't react any better, it could be a power problem.
Do you have a common ground between the arduino and the breadboard? If that power supply is putting out 5V, the voltage drop through the L293D will reduce it by 1.4V to 3.6V and might run the motor much slower/weaker than if it were directly connected to 5V
Hi, @vertily
Welcome to the forum.
Thanks for using code tags.
Can you please post a copy of your complete circuit, a picture of a hand drawn circuit in jpg, png?
Hand drawn and photographed is perfectly acceptable.
Please include ALL hardware, power supplies, component names and pin labels.
Can you post some images of your project?
So we can see your component layout.
Have you got the gnd of the UNO connected to the gnd of the protoboard?