![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Final
Dependencies: Crypto_light mbed-rtos mbed regex
Fork of EMBEDDED_CW2 by
Diff: main.cpp
- Revision:
- 3:569b35e2a602
- Parent:
- 2:4e88faab6988
- Child:
- 4:e322ca760c63
diff -r 4e88faab6988 -r 569b35e2a602 main.cpp --- a/main.cpp Tue Feb 28 14:44:23 2017 +0000 +++ b/main.cpp Thu Mar 01 09:41:46 2018 +0000 @@ -1,5 +1,4 @@ #include "mbed.h" -#include "rtos.h" //Photointerrupter input pins #define I1pin D2 @@ -38,7 +37,7 @@ //const int8_t stateMap[] = {0x07,0x01,0x03,0x02,0x05,0x00,0x04,0x07}; //Alternative if phase order of input or drive is reversed //Phase lead to make motor spin -const int8_t lead = -2; //2 for forwards, -2 for backwards +const int8_t lead = 2; //2 for forwards, -2 for backwards //Status LED DigitalOut led1(LED1); @@ -88,7 +87,7 @@ int8_t motorHome() { //Put the motor in drive state 0 and wait for it to stabilise motorOut(0); - wait(1.0); + wait(2.0); //Get the rotor state return readRotorState(); @@ -97,11 +96,11 @@ //Main int main() { int8_t orState = 0; //Rotot offset at motor state 0 + int8_t intState = 0; + int8_t intStateOld = 0; //Initialise the serial port Serial pc(SERIAL_TX, SERIAL_RX); - int8_t intState = 0; - int8_t intStateOld = 0; pc.printf("Hello\n\r"); //Run the motor synchronisation