jordan harper
/
ServoControl
main.cpp@2:baf8a7b2b150, 2017-02-07 (annotated)
- Committer:
- jordaahh
- Date:
- Tue Feb 07 14:21:54 2017 +0000
- Revision:
- 2:baf8a7b2b150
- Parent:
- 0:b5ce567b469c
- Child:
- 3:306d3725ed04
error in SystemFunctions.c (LDR1, LDR2, LDR3, LDR4 is underdefined)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jordaahh | 0:b5ce567b469c | 1 | // Hello World to sweep a servo through its full range |
jordaahh | 2:baf8a7b2b150 | 2 | |
jordaahh | 0:b5ce567b469c | 3 | #include "mbed.h" |
jordaahh | 0:b5ce567b469c | 4 | #include "Servo.h" |
jordaahh | 0:b5ce567b469c | 5 | #include "SystemFunctions.h" |
jordaahh | 0:b5ce567b469c | 6 | |
jordaahh | 2:baf8a7b2b150 | 7 | Servo servo1(p21); // PWM out to servo in first axis (Solar Azimuth) |
jordaahh | 2:baf8a7b2b150 | 8 | Servo servo2(p22); // PWM out to servo in second axis (Solar Altitude) |
jordaahh | 2:baf8a7b2b150 | 9 | |
jordaahh | 2:baf8a7b2b150 | 10 | AnalogIn pot(p20); // Linear pot input for manual control [initial circuit] |
jordaahh | 2:baf8a7b2b150 | 11 | |
jordaahh | 2:baf8a7b2b150 | 12 | AnalogIn LDR1(p15); // Top Left LDR |
jordaahh | 2:baf8a7b2b150 | 13 | AnalogIn LDR2(p16); // Top Right LDR |
jordaahh | 2:baf8a7b2b150 | 14 | AnalogIn LDR3(p17); // Bottom Left LDR |
jordaahh | 2:baf8a7b2b150 | 15 | AnalogIn LDR4(p18); // Bottom Right LDR |
jordaahh | 0:b5ce567b469c | 16 | |
jordaahh | 0:b5ce567b469c | 17 | int main() { |
jordaahh | 0:b5ce567b469c | 18 | |
jordaahh | 0:b5ce567b469c | 19 | servo1.calibrate(range, 45.0); // *****check this fucntion****** |
jordaahh | 0:b5ce567b469c | 20 | |
jordaahh | 0:b5ce567b469c | 21 | while(1){ |
jordaahh | 0:b5ce567b469c | 22 | // initial code for testing one servo with a linear potentiometer. |
jordaahh | 0:b5ce567b469c | 23 | position = pot; |
jordaahh | 0:b5ce567b469c | 24 | wait_ms(0.5); |
jordaahh | 0:b5ce567b469c | 25 | servo1 = position; |
jordaahh | 0:b5ce567b469c | 26 | } |
jordaahh | 0:b5ce567b469c | 27 | } |
jordaahh | 0:b5ce567b469c | 28 |