Dependencies: Servo TextLCD mbed
main.cpp
- Committer:
- clementb
- Date:
- 2016-06-14
- Revision:
- 1:c3a33d9372f5
- Parent:
- 0:9438fe754ab6
- Child:
- 2:2728901fd798
File content as of revision 1:c3a33d9372f5:
#include "mbed.h" #include "TextLCD.h" #include "Servo.h" TextLCD lcd(D12, D11, D5, D4, D3, D2); Servo servoRL(D10); Servo servoHL(D9); DigitalIn menu(USER_BUTTON); DigitalOut led(LED1); int page; int j = 0; int xPos = 0; int yPos = 0; int servoRLMov(int version){ if(version==1){ //From left to righ for(int i=0; i==100; i=i+0.01){ servoRL = i; wait(0.01); } } else if(version==2){ //From righ to left for(int i=100;i==0; i=i-0.01){ servoRL = i; wait(0.01); } } return 0; } int servoHLMov(int version){ if(version==1){ //From low to high for(int i=0; i==100; i=i+0.01){ servoHL = i; wait(0.01); } } else if(version==2){ //From high to low for(int i=100; i==0; i=i-0.01){ servoHL = i; wait(0.01); } } return 0; } int main(){ page = 1; lcd.cls(); lcd.locate(0,0); lcd.printf("BIXI - demo arm\n"); lcd.locate(0,1); lcd.printf("Clement BALLOT\n"); servoRL = 0; servoHL = 0; while(j != 30){ led = 1; wait(0.05); led = 0; wait(0.05); j = j++; } while(1) { if(menu == 0) { page = page++; if(page >4){ page = 1; } } wait(1); if(page == 4) { lcd.cls(); lcd.locate(0,0); lcd.printf("Loading P4... "); lcd.locate(0,1); lcd.printf("P4 : low > high "); wait(2); lcd.locate(0,0); lcd.printf("Running P4... "); led = 1; wait(0.2); led = 0; wait(0.2); led = 1; wait(0.2); led = 0; wait(0.2); led = 1; wait(0.2); led = 0; wait(0.2); led = 1; wait(0.2); led = 0; } else if(page == 3) { lcd.cls(); lcd.locate(0,0); lcd.printf("Loading P3... "); lcd.locate(0,1); lcd.printf("P3 : righ > left"); wait(2); lcd.locate(0,0); lcd.printf("Running P3... "); led = 1; wait(0.2); led = 0; wait(0.2); led = 1; wait(0.2); led = 0; wait(0.2); led = 1; wait(0.2); led = 0; } else if(page == 2) { lcd.cls(); lcd.locate(0,0); lcd.printf("Loading P2..."); lcd.locate(0,1); lcd.printf("P2 : high > low "); wait(2); lcd.locate(0,0); lcd.printf("Running P2... "); led = 1; wait(0.2); led = 0; wait(0.2); led = 1; wait(0.2); led = 0; } else if(page == 1) { lcd.cls(); lcd.locate(0,0); lcd.printf("Loading P1... "); lcd.locate(0,1); lcd.printf("P1 : left > righ"); wait(2); lcd.locate(0,0); lcd.printf("Running P1... "); lcd.locate(0,0); led = 1; wait(0.2); led = 0; } } }