Robot that currently does nothing

Dependencies:   4DGL-uLCD-SE SDFileSystem ShiftBrite mbed-rtos mbed wave_player Motor

Files at this revision

API Documentation at this revision

Comitter:
jplager3
Date:
Thu Mar 16 01:28:27 2017 +0000
Parent:
7:df218a6a1a01
Child:
9:37bb5f0e2975
Commit message:
Successful independent control of both motors.; Issue: Left motor runs at max speed for ~1s on startup and idk why.

Changed in this revision

Motor.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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Motor.lib	Thu Mar 16 01:28:27 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/simon/code/Motor/#f265e441bcd9
--- a/main.cpp	Wed Mar 15 21:12:03 2017 +0000
+++ b/main.cpp	Thu Mar 16 01:28:27 2017 +0000
@@ -4,6 +4,7 @@
 //#include "ShiftBrite.h"
 #include "SDFileSystem.h"
 #include "wave_player.h"
+#include "Motor.h"
 
 Mutex mutex;    //
 Mutex mutex2;   //
@@ -15,20 +16,19 @@
 Thread thread2;
 Thread thread3;
 Thread thread4;
-//DigitalOut latch(p15);
-//DigitalOut enable(p16);
 SPI spi(p11, p12, p13);
-//uLCD_4DGL uLCD(p28,p27,p29); //(p27, p28, p30);    //tx, rx, rst
 uLCD_4DGL uLCD(p28, p27, p30); 
-//ShiftBrite myBrite(p15,p16,spi); //latch, enable, spi
 SDFileSystem sd(p5, p6, p7, p8, "sd"); //SD card
 AnalogOut DACout(p18);      //must be p18
 AnalogIn IR(p20);
-//RawSerial BT(p9, p10);  //bluetooth pinout
 FILE *wave_file = NULL;         //global bc its gotta be changed by Main while running in child thread
 FILE *wave_file2 = NULL;
 wave_player waver(&DACout);     //create wave_player object for speaker
-
+//create objects for Motor Control
+//PwmOut motorL(p21);           // doesnt seem to work
+//Motor Left(p21, p12, p11); //, p6, p5, 1); // pwm, fwd, rev, can brake
+Motor Left(p21, p14, p13);      // green wires. pwm, fwd, rev, add ", 1" for braking
+Motor Right(p22, p12, p11);     // red wires
 void LCD_thread1() {
     while(1){    
         mutex.lock();
@@ -65,12 +65,23 @@
 }
 
 int main() {
+    Left.speed(0.0);
+    Right.speed(0.0);
     //thread1.start(IR_thread); // read in IR data
     thread2.start(LCD_thread1);   
     //thread3.start(Motor_thread);
     thread4.start(sound_thread);
     
     while(1){
+        //motor testing
+        //motorL.write(.8);
+        
+        for(float i=0.5;i>0.0;i-=0.1){
+            Left.speed(i);
+            Right.speed(-i);
+            wait(0.75);
+        }
+        
         //IR testing
         if(IR>0.3 && IR<0.5) {
             led1=1;
@@ -92,6 +103,7 @@
              *
              *
              */
+            //motorL.write(.5);
             // write reverse values to the motors for N rotations
             // execute turn by stopping one wheel, and turning the other (trial and error to find exact rotation?)
             // jump back to normal behavior