Daniqe Kottelenberg / Mbed 2 deprecated check_motoren_buttons

Dependencies:   MODSERIAL QEI mbed

Fork of check_motoren_buttons_emg by Daniqe Kottelenberg

Files at this revision

API Documentation at this revision

Comitter:
daniQQue
Date:
Fri Sep 30 13:10:39 2016 +0000
Parent:
11:757787c47d3c
Child:
13:ba5713727343
Commit message:
wait eruit + led erin;

Changed in this revision

MODSERIAL.lib Show annotated file Show diff for this revision Revisions of this file
QEI.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MODSERIAL.lib	Fri Sep 30 13:10:39 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/Sissors/code/MODSERIAL/#8ef4f91813fd
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/QEI.lib	Fri Sep 30 13:10:39 2016 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/aberk/code/QEI/#5c2ad81551aa
--- a/main.cpp	Fri Sep 30 12:34:46 2016 +0000
+++ b/main.cpp	Fri Sep 30 13:10:39 2016 +0000
@@ -1,10 +1,14 @@
-#include "mbed.h"
-//#include "MODSERIAL.h"
- 
-DigitalOut led(LED_RED);
-DigitalOut led2(LED_BLUE);
+#include "mbed.h" //standaard bieb mbed
+#include "QEI.h"  //bieb voor encoderfuncties in c++
+#include "MODSERIAL.h" //bieb voor modserial
 InterruptIn sw3(SW3);
-Serial pc(USBTX, USBRX);
+DigitalIn encoder1A(D13); 
+DigitalIn encoder1B(D12);
+DigitalIn button_cw(D11);
+DigitalIn button_ccw(D9);
+DigitalOut ledcw(D10);
+DigitalOut ledccw(D2);
+MODSERIAL pc(USBTX, USBRX);
 DigitalOut richting_motor1(D4);
 PwmOut pwm_motor1(D5);
 DigitalOut richting_motor2(D7);
@@ -25,10 +29,8 @@
     sw3.fall(&SwitchN);                  // zorgt er voor dat void switch wordt gedaan als switch 3 wordt ingedrukt
     
     
-    char c = pc.getc();                 // zorgt ervoor dat er in het toetsenboard characters gebruikt kunnen worden
-    pc.printf("%c \n\r",c);
-    
-    if (c=='s')                           // als s ingedrukt wordt gebeurd het volgende
+   
+    if (button_cw==0)                           // als s ingedrukt wordt gebeurd het volgende
     {
          if (n%2==0)                     // als s ingedrukt wordt en het getal is even gebeurd het onderstaande
          {
@@ -36,7 +38,8 @@
            pc.printf("up \n\r");        // print lijn "up"   
            richting_motor1 = 1;
            pwm_motor1 = 1; 
-           wait (0.05);
+           ledcw=1; ledccw=0;
+          
          } 
          
          else                           // als s is ingedrukt maar het getal is niet even (dus oneven) gebeurdt het onderstaande
@@ -45,11 +48,12 @@
            pc.printf("left \n\r");      // print lijn "left"
            richting_motor2 = 1;
            pwm_motor2 = 1;
-          wait (0.05);
+           ledcw=1;
+           ledccw=1;
          }      
               
     }
-    else if (c=='d')                     // als d ingedrukt wordt gebeurd het volgende
+    else if (button_ccw==0)                     // als d ingedrukt wordt gebeurd het volgende
     {
          if (n%2==0)                     // als d is ingedrukt en n is even dan gebeurd het volgende
          {
@@ -57,7 +61,8 @@
            pc.printf("down \n\r");      // print lijn "down"   
            richting_motor1 = 0;
            pwm_motor1 = 1;
-           wait (0.05);
+           ledccw=1; ledcw=0;
+         
            
          } 
          else                           // als d is ingedrukt maar het getal is niet even (dus oneven) gebeurdt het onderstaande
@@ -66,13 +71,15 @@
            pc.printf("right \n\r");    // print lijn "right"
            richting_motor2 = 0;
            pwm_motor2 = 1;
-           wait (0.05); 
+           ledccw=1; ledcw=0;
+        
          }  
     }   
     else{
        pc.printf("motor staat stil \n\r");
     pwm_motor2=0;
     pwm_motor1=0;
+    ledccw=0; ;ledcw=0
     }              
       
            
--- a/mbed.bld	Fri Sep 30 12:34:46 2016 +0000
+++ b/mbed.bld	Fri Sep 30 13:10:39 2016 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/abea610beb85
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed/builds/8ed44a420e5c