color sorting robot
Dependencies: ID12RFID ColorSortingRobot mbed
Fork of ServoProgram by
main.cpp@0:7b3eabfa1a0f, 2010-05-18 (annotated)
- Committer:
- simon
- Date:
- Tue May 18 19:40:18 2010 +0000
- Revision:
- 0:7b3eabfa1a0f
- Child:
- 1:4c80434e0d26
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
simon | 0:7b3eabfa1a0f | 1 | #include "mbed.h" |
simon | 0:7b3eabfa1a0f | 2 | #include "Servo.h" |
simon | 0:7b3eabfa1a0f | 3 | |
simon | 0:7b3eabfa1a0f | 4 | Servo myservo(p21); |
simon | 0:7b3eabfa1a0f | 5 | Serial pc(USBTX, USBRX); |
simon | 0:7b3eabfa1a0f | 6 | |
simon | 0:7b3eabfa1a0f | 7 | int main() { |
simon | 0:7b3eabfa1a0f | 8 | printf("Servo Calibration Controls:\n"); |
simon | 0:7b3eabfa1a0f | 9 | printf("1,2,3 - Position Servo (full left, middle, full right)\n"); |
simon | 0:7b3eabfa1a0f | 10 | printf("4,5 - Decrease or Increase range\n"); |
simon | 0:7b3eabfa1a0f | 11 | |
simon | 0:7b3eabfa1a0f | 12 | float range = 0.0005; |
simon | 0:7b3eabfa1a0f | 13 | float position = 0.5; |
simon | 0:7b3eabfa1a0f | 14 | |
simon | 0:7b3eabfa1a0f | 15 | while(1) { |
simon | 0:7b3eabfa1a0f | 16 | switch(pc.getc()) { |
simon | 0:7b3eabfa1a0f | 17 | case '1': position = 0.0; break; |
simon | 0:7b3eabfa1a0f | 18 | case '2': position = 0.5; break; |
simon | 0:7b3eabfa1a0f | 19 | case '3': position = 1.0; break; |
simon | 0:7b3eabfa1a0f | 20 | case '4': range += 0.0001; break; |
simon | 0:7b3eabfa1a0f | 21 | case '5': range -= 0.0001; break; |
simon | 0:7b3eabfa1a0f | 22 | } |
simon | 0:7b3eabfa1a0f | 23 | printf("position = %.1f, range = +/-%0.4f\n", position, range); |
simon | 0:7b3eabfa1a0f | 24 | myservo.calibrate(range, 45.0); |
simon | 0:7b3eabfa1a0f | 25 | myservo = position; |
simon | 0:7b3eabfa1a0f | 26 | } |
simon | 0:7b3eabfa1a0f | 27 | } |