Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: Servo TextLCD mbed
Diff: main.cpp
- Revision:
- 1:c3a33d9372f5
- Parent:
- 0:9438fe754ab6
- Child:
- 2:2728901fd798
--- a/main.cpp Mon Jun 13 14:28:54 2016 +0000
+++ b/main.cpp Tue Jun 14 13:49:24 2016 +0000
@@ -3,114 +3,154 @@
#include "Servo.h"
-
-
TextLCD lcd(D12, D11, D5, D4, D3, D2);
-Servo servoRL(D8);
-Servo servoHL(D7);
+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 main()
-{
-/*---------------------------------------------------"Home screen"-------------------------------------------------------------------------*/
- lcd.cls();
- lcd.locate(0,0);
- lcd.printf("BIXI robotic arm");
- lcd.locate(0,1);
- lcd.printf("test program");
- wait(2);
-
-/*-------------------------------------------------Movement selection---------------------------------------------------------------------------*/
- menu:
+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("Choose movement :");
- page = 1;
-
- while(1) {
- if(menu == 1) {
- if(page == 4) {
- page = 1;
- }
- else if(page == 3) {
- page = 4;
- }
- else if(page == 2) {
- page = 3;
- }
- else if(page == 1) {
- page = 2;
- }
+ 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++;
}
- if(page == 1) {
- lcd.locate(0,1);
- lcd.printf("Righ to left");
- goto righLeft;
- }
- else if(page == 2) {
- lcd.locate(0,1);
- lcd.printf("High to low");
- goto highLow;
- }
- else if(page == 3) {
- lcd.locate(0,1);
- lcd.printf("Left to righ");
- goto leftRigh;
- }
- else if(page == 4) {
- lcd.locate(0,1);
- lcd.printf("Low to high");
- goto lowHigh;
- }
-
-/*----------------------------------------------Righ to left rotation--------------------------------------------------*/
- righLeft:
- for(int i = xPos; i==100; i=i+0.1){
- servoRL = i;
+ while(1) {
+ if(menu == 0) {
+ page = page++;
+ if(page >4){
+ page = 1;
+ }
}
- xPos = 100;
- wait(1);
- servoRL = 0;
- goto menu;
-
-/*---------------------------------------------High to low translation--------------------------------------------------*/
- highLow:
- for(int i = yPos; i==100; i=i+0.1){
- servoHL = i;
- }
- yPos = 100;
- wait(1);
- servoHL = 0;
- goto menu;
-
-/*--------------------------------------------Left to righ rotation---------------------------------------------------*/
- leftRigh:
- for(int i = xPos; i == 0; i=i-0.1){
- servoRL = i;
- }
- xPos = 0;
- wait(1);
- servoRL = 100;
- goto menu;
-
-/*---------------------------------------------Low to high translation-----------------------------------------------*/
- lowHigh:
- for(int i = yPos; i==0; i=i-0.1){
- servoHL = i;
- }
- yPos = 0;
- wait(1);
- servoHL = 100;
- goto menu;
-}
+
+ 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;
+ }
+ }
}
\ No newline at end of file