Start of project 2

Dependencies:   Motor Servo mbed mbed-rtos

main.cpp.orig

Committer:
m215676
Date:
2018-10-22
Revision:
7:adcdd7556997
Parent:
4:a3e95c9d56d5

File content as of revision 7:adcdd7556997:

#include "mbed.h"
#include "stdio.h"
#include "Motor.h"
#include "math.h"
#include "Servo.h"

int s1, s3, s4, i;
float x;
DigitalIn swtch1(p19);
DigitalIn swtch3(p20);
DigitalIn swtch4(p21);
AnalogIn turn(p22);
Motor m(p26, p30, p29);

Servo back(p21);
Servo angle(p22);

int main() {
    s1 = swtch1.read(); //read state of switch 1
    back.calibrate(0.0009, 90.0); //calculate's servos timing by setting pulse width and range
    
    while (s1 == 1)
    {
       for (i = 0; i < 18; i++) //moves monument forward
       {
       back = 0;
       back = (0.0 + (i/18.0));
     s1 = swtch1.read(); //read state of switch 1
      }//end of for loop
      
      for (i = 0; i < 35; i++)  //moves monument backwards
       {
       back = 1;
       back = (1.0 - (i/18.0));
     s1 = swtch1.read(); //read state of switch 1
      }//end of for loop
      
      }//end of while loop
      
      
      while (1)
      {
        x = turn.read();
        angle = x;
        wait (.05);
          
          } //end of while loop
      
    } //end of int main