Lab 2 RC

Dependencies:   Motor Servo mbed

Committer:
mattsims12
Date:
Tue Oct 13 17:49:34 2015 +0000
Revision:
2:26ae66987e9f
Parent:
1:55b6172d1930
Lab 2 RC

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mattsims12 0:7af9f9bb814c 1 /*Matthew Sims
mattsims12 0:7af9f9bb814c 2 RC Control
mattsims12 0:7af9f9bb814c 3 Moves a servo back in forth in small incriments
mattsims12 0:7af9f9bb814c 4 10/13/15
mattsims12 0:7af9f9bb814c 5 */
mattsims12 0:7af9f9bb814c 6
mattsims12 1:55b6172d1930 7 #include "mbed.h" //include libraries
mattsims12 0:7af9f9bb814c 8 #include "Motor.h"
mattsims12 0:7af9f9bb814c 9 #include "Servo.h"
mattsims12 0:7af9f9bb814c 10
mattsims12 1:55b6172d1930 11 Servo s(p21); //Initiate servo
mattsims12 0:7af9f9bb814c 12
mattsims12 0:7af9f9bb814c 13 int main()
mattsims12 0:7af9f9bb814c 14 {
mattsims12 1:55b6172d1930 15 s.calibrate(.0009,90); //Calibrate servo
mattsims12 0:7af9f9bb814c 16
mattsims12 0:7af9f9bb814c 17 while(1) {
mattsims12 1:55b6172d1930 18 for(int pos=0; pos<=18; pos++) { //Moves 18 positions
mattsims12 2:26ae66987e9f 19 s=pos/18.0; //Moves 1/18 of the distance
mattsims12 1:55b6172d1930 20 getchar(); //Wait for button press
mattsims12 0:7af9f9bb814c 21 }
mattsims12 1:55b6172d1930 22 for(int pos=18; pos>=0; pos--) { //Same as last loop, but backwards
mattsims12 2:26ae66987e9f 23 s=pos/18.0;
mattsims12 0:7af9f9bb814c 24 getchar();
mattsims12 0:7af9f9bb814c 25 }
mattsims12 0:7af9f9bb814c 26 }
mattsims12 0:7af9f9bb814c 27 }