KL25Z firmware. Responsible for activating the servo based on input from the nRF51822.
Fork of HW5_Servo by
Revision 2:13e9c2f5ca10, committed 2014-11-10
- Comitter:
- adarsh5723
- Date:
- Mon Nov 10 11:31:24 2014 +0000
- Parent:
- 1:19dd18051447
- Commit message:
- KL25Z firmware.; Responsible for activating the servo based on input from the nRF51822.
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 19dd18051447 -r 13e9c2f5ca10 main.cpp --- a/main.cpp Mon Nov 10 03:55:53 2014 +0000 +++ b/main.cpp Mon Nov 10 11:31:24 2014 +0000 @@ -4,14 +4,14 @@ #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 -#define THRESHOLD .001 -int counter = 0; Serial pc(USBTX, USBRX); int main() { @@ -20,9 +20,6 @@ bool servoLogic = 0; while(1){ - - - #if 1 if (toggleSwitch == 1) //if (ldr0.read() > 0.7) servoLogic = 1; @@ -31,30 +28,15 @@ //recieve_data(ServoLogic); if (servoLogic) { - float o = 0.0; - myservo = o; + myservo = 0.0f; } else{ - float f= 1; - myservo = f; + + myservo = 1.0f; } + //For debugging purposes +#if DEBUG printf("%f\n\r",ldr0.read()); - #else -#if 0 - int pos = 0; - for(pos = 0; pos < 100; pos += 1) // goes from 0 degrees to 180 degrees - { // in steps of 1 degree - myservo = pos/100; // tell servo to go to position in variable 'pos' - wait(0.015); // waits 15ms for the servo to reach the position - } - for(pos = 100; pos>=1; pos-=1) // goes from 180 degrees to 0 degrees - { - myservo = pos/100; // tell servo to go to position in variable 'pos' - wait(0.015); // waits 15ms for the servo to reach the position - } -#else - myservo = 2; -#endif #endif wait(.2); }