jordi solorzano
/
ClaseCarmona_softpotYservo
main.cpp@0:bc20c8ff0a0b, 2013-12-12 (annotated)
- Committer:
- gestug
- Date:
- Thu Dec 12 20:34:51 2013 +0000
- Revision:
- 0:bc20c8ff0a0b
softpot
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
gestug | 0:bc20c8ff0a0b | 1 | #include "mbed.h" |
gestug | 0:bc20c8ff0a0b | 2 | #include "Servo.h" |
gestug | 0:bc20c8ff0a0b | 3 | |
gestug | 0:bc20c8ff0a0b | 4 | AnalogIn sensor(PTB1); |
gestug | 0:bc20c8ff0a0b | 5 | Servo servo(PTD4); |
gestug | 0:bc20c8ff0a0b | 6 | Serial pc(USBTX, USBRX); // tx, rx |
gestug | 0:bc20c8ff0a0b | 7 | |
gestug | 0:bc20c8ff0a0b | 8 | int main() { |
gestug | 0:bc20c8ff0a0b | 9 | |
gestug | 0:bc20c8ff0a0b | 10 | float softpot; |
gestug | 0:bc20c8ff0a0b | 11 | servo.calibrate(0.001,45); |
gestug | 0:bc20c8ff0a0b | 12 | |
gestug | 0:bc20c8ff0a0b | 13 | while(1){ |
gestug | 0:bc20c8ff0a0b | 14 | |
gestug | 0:bc20c8ff0a0b | 15 | softpot=sensor; |
gestug | 0:bc20c8ff0a0b | 16 | |
gestug | 0:bc20c8ff0a0b | 17 | if(softpot>0.1) |
gestug | 0:bc20c8ff0a0b | 18 | { |
gestug | 0:bc20c8ff0a0b | 19 | servo.write( softpot); |
gestug | 0:bc20c8ff0a0b | 20 | wait(.2); |
gestug | 0:bc20c8ff0a0b | 21 | pc.printf("softpot:%f\n",softpot); |
gestug | 0:bc20c8ff0a0b | 22 | } |
gestug | 0:bc20c8ff0a0b | 23 | } |
gestug | 0:bc20c8ff0a0b | 24 | |
gestug | 0:bc20c8ff0a0b | 25 | } |