![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Joystick Controlled Servos
main.cpp@0:7e748374bdff, 2018-12-12 (annotated)
- Committer:
- Galib_Rahman
- Date:
- Wed Dec 12 17:31:29 2018 +0000
- Revision:
- 0:7e748374bdff
- Child:
- 1:6dc9dbf60e67
Simran's Joystick Controlled Servos
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Galib_Rahman | 0:7e748374bdff | 1 | /* |
Galib_Rahman | 0:7e748374bdff | 2 | |
Galib_Rahman | 0:7e748374bdff | 3 | Joystick Controlled Servo Motors |
Galib_Rahman | 0:7e748374bdff | 4 | Developed 12|12|18 |
Galib_Rahman | 0:7e748374bdff | 5 | Courtesy of Galib F. Rahman |
Galib_Rahman | 0:7e748374bdff | 6 | |
Galib_Rahman | 0:7e748374bdff | 7 | |
Galib_Rahman | 0:7e748374bdff | 8 | */ |
Galib_Rahman | 0:7e748374bdff | 9 | |
Galib_Rahman | 0:7e748374bdff | 10 | #include "mbed.h" |
Galib_Rahman | 0:7e748374bdff | 11 | #include "Servo.h" |
Galib_Rahman | 0:7e748374bdff | 12 | #include "Map.hpp" |
Galib_Rahman | 0:7e748374bdff | 13 | |
Galib_Rahman | 0:7e748374bdff | 14 | |
Galib_Rahman | 0:7e748374bdff | 15 | AnalogIn JoystickPin1(A0); |
Galib_Rahman | 0:7e748374bdff | 16 | AnalogIn JoystickPin2(A1); |
Galib_Rahman | 0:7e748374bdff | 17 | |
Galib_Rahman | 0:7e748374bdff | 18 | Servo ServoMotor1(D3); |
Galib_Rahman | 0:7e748374bdff | 19 | Servo ServoMotor2(D4); |
Galib_Rahman | 0:7e748374bdff | 20 | |
Galib_Rahman | 0:7e748374bdff | 21 | Map AnalogPos(0,1023,0,180); |
Galib_Rahman | 0:7e748374bdff | 22 | |
Galib_Rahman | 0:7e748374bdff | 23 | |
Galib_Rahman | 0:7e748374bdff | 24 | int main() |
Galib_Rahman | 0:7e748374bdff | 25 | { |
Galib_Rahman | 0:7e748374bdff | 26 | |
Galib_Rahman | 0:7e748374bdff | 27 | float Position1,Position2; |
Galib_Rahman | 0:7e748374bdff | 28 | |
Galib_Rahman | 0:7e748374bdff | 29 | |
Galib_Rahman | 0:7e748374bdff | 30 | while (true) { |
Galib_Rahman | 0:7e748374bdff | 31 | |
Galib_Rahman | 0:7e748374bdff | 32 | Position1=AnalogPos.Calculate(JoystickPin1); |
Galib_Rahman | 0:7e748374bdff | 33 | Position2=AnalogPos.Calculate(JoystickPin2); |
Galib_Rahman | 0:7e748374bdff | 34 | |
Galib_Rahman | 0:7e748374bdff | 35 | |
Galib_Rahman | 0:7e748374bdff | 36 | ServoMotor1.position(Position1); |
Galib_Rahman | 0:7e748374bdff | 37 | ServoMotor2.position(Position2); |
Galib_Rahman | 0:7e748374bdff | 38 | |
Galib_Rahman | 0:7e748374bdff | 39 | |
Galib_Rahman | 0:7e748374bdff | 40 | |
Galib_Rahman | 0:7e748374bdff | 41 | } |
Galib_Rahman | 0:7e748374bdff | 42 | } |