KL25Z firmware. Responsible for activating the servo based on input from the nRF51822.

Dependencies:   Servo mbed

Fork of HW5_Servo by StepSense

main.cpp

Committer:
adarsh5723
Date:
2014-11-10
Revision:
2:13e9c2f5ca10
Parent:
1:19dd18051447

File content as of revision 2:13e9c2f5ca10:

// Hello World to sweep a servo through its full range

#include "mbed.h"
#include "Servo.h"


#define DEBUG 0

DigitalIn toggleSwitch(D3);
//debugging Analog in
AnalogIn ldr0(A5);
PwmOut servoDriver(D2);
Servo myservo(D2); //change digital pin here


Serial pc(USBTX, USBRX);
int main() {
    //myservo.position(270.0f);
    myservo.calibrate(.0006, 120.0); 
    bool servoLogic = 0;
    
    while(1){
        if (toggleSwitch == 1)
        //if (ldr0.read() > 0.7)
            servoLogic = 1;
        else
            servoLogic = 0;
        //recieve_data(ServoLogic);
        if (servoLogic)
        {
            myservo = 0.0f;
        }
        else{

            myservo = 1.0f;
        }
        //For debugging purposes
#if DEBUG        
        printf("%f\n\r",ldr0.read());
#endif
        wait(.2);
    }
}