![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Joystick Controlled Servos
Diff: main.cpp
- Revision:
- 0:7e748374bdff
- Child:
- 1:6dc9dbf60e67
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Dec 12 17:31:29 2018 +0000 @@ -0,0 +1,42 @@ +/* + + Joystick Controlled Servo Motors + Developed 12|12|18 + Courtesy of Galib F. Rahman + + + */ + +#include "mbed.h" +#include "Servo.h" +#include "Map.hpp" + + +AnalogIn JoystickPin1(A0); +AnalogIn JoystickPin2(A1); + +Servo ServoMotor1(D3); +Servo ServoMotor2(D4); + +Map AnalogPos(0,1023,0,180); + + +int main() +{ + + float Position1,Position2; + + + while (true) { + + Position1=AnalogPos.Calculate(JoystickPin1); + Position2=AnalogPos.Calculate(JoystickPin2); + + + ServoMotor1.position(Position1); + ServoMotor2.position(Position2); + + + + } +}