Last active
May 23, 2017 01:58
-
-
Save yue82/e72b7e7aa786dc33fb6b4e5bdc8aad0f to your computer and use it in GitHub Desktop.
LPC824 trial
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include "mbed.h" | |
| AnalogIn sensor[] = {dp19, dp20, dp21}; | |
| BusOut mdA(dp7, dp6); | |
| BusOut mdB(dp9, dp8); | |
| Serial pc(USBTX, USBRX); | |
| int motorTest(int code){ | |
| switch(code){ | |
| case 1: | |
| mdA = 0b10; | |
| mdB = 0b00; | |
| break; | |
| case 2: | |
| mdA = 0b00; | |
| mdB = 0b10; | |
| break; | |
| case 3: | |
| mdA = 0b01; | |
| mdB = 0b00; | |
| break; | |
| case 4: | |
| mdA = 0b00; | |
| mdB = 0b01; | |
| break; | |
| case 5: | |
| mdA = 0b10; | |
| mdB = 0b10; | |
| break; | |
| case 6: | |
| mdA = 0b01; | |
| mdB = 0b01; | |
| break; | |
| default: | |
| mdA = 0b11; | |
| mdB = 0b11; | |
| code = 0; | |
| break; | |
| } | |
| return code++; | |
| } | |
| int main() | |
| { | |
| int code = 0; | |
| mdA = 0b11; | |
| mdB = 0b11; | |
| while(1) { | |
| pc.printf("Test code: %d\r\n", code); | |
| code = motorTest(code); | |
| wait(1.0); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment