![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Joystick Controlled Servos
Revision 1:6dc9dbf60e67, committed 2018-12-13
- Comitter:
- Galib_Rahman
- Date:
- Thu Dec 13 02:26:26 2018 +0000
- Parent:
- 0:7e748374bdff
- Commit message:
- Modified Analog.read()
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 7e748374bdff -r 6dc9dbf60e67 main.cpp --- a/main.cpp Wed Dec 12 17:31:29 2018 +0000 +++ b/main.cpp Thu Dec 13 02:26:26 2018 +0000 @@ -2,7 +2,7 @@ Joystick Controlled Servo Motors Developed 12|12|18 - Courtesy of Galib F. Rahman + */ @@ -16,27 +16,40 @@ AnalogIn JoystickPin2(A1); Servo ServoMotor1(D3); -Servo ServoMotor2(D4); +//Servo ServoMotor2(D4); Map AnalogPos(0,1023,0,180); + int main() { - - float Position1,Position2; + + float Position1,Position2; while (true) { - Position1=AnalogPos.Calculate(JoystickPin1); - Position2=AnalogPos.Calculate(JoystickPin2); + Position1=AnalogPos.Calculate(JoystickPin1.read()); + Position2=AnalogPos.Calculate(JoystickPin2.read()); + - ServoMotor1.position(Position1); - ServoMotor2.position(Position2); + ServoMotor1.position(Position1); + printf("JoyStick1"); + printf("%f",Position1); + + printf("JoyStick2"); + + printf("%f",Position2); + + + ServoMotor1.position(Position1); + } + + } -} +