ECE4180 lab4

Dependencies:   EthernetNetIf HTTPServer Motordriver NetServicesSource mbed

Fork of HTTPServerExample by Donatien Garnier

Files at this revision

API Documentation at this revision

Comitter:
tianyeapply
Date:
Thu Nov 03 21:45:57 2016 +0000
Parent:
2:f8e64bf9a474
Commit message:
Code for ECE 4180 Lab4, remote control a Moto

Changed in this revision

HTTPServerExample.cpp Show annotated file Show diff for this revision Revisions of this file
Motordriver.lib Show annotated file Show diff for this revision Revisions of this file
NetServicesSource.lib Show annotated file Show diff for this revision Revisions of this file
--- a/HTTPServerExample.cpp	Fri Jul 09 14:46:03 2010 +0000
+++ b/HTTPServerExample.cpp	Thu Nov 03 21:45:57 2016 +0000
@@ -1,17 +1,24 @@
 #include "mbed.h"
 #include "EthernetNetIf.h"
 #include "HTTPServer.h"
-
+#include "motordriver.h"
 DigitalOut led1(LED1, "led1");
 DigitalOut led2(LED2, "led2");
 DigitalOut led3(LED3, "led3");
 DigitalOut led4(LED4, "led4");
+AnalogIn pot(p20);
 
 LocalFileSystem fs("webfs");
 
 EthernetNetIf eth;  
 HTTPServer svr;
 
+// Magician robot motor test
+
+//Connections to dual H-brdige driver for the two drive motors
+Motor  left(p21, p22, p23, 1); // pwm, fwd, rev, has brake feature
+
+
 int main() {
   Base::add_rpc_class<DigitalOut>();
 
@@ -40,12 +47,31 @@
   Timer tm;
   tm.start();
   //Listen indefinitely
+  
+  float speed;
   while(true)
-  {
+  {     
     Net::poll();
+    speed = pot.read();
+    if(led1==1){
+       left.speed(speed);
+       led1=0;
+        //start    
+    }
+    else if(led2 ==1){
+        //stop 
+        left.speed(0);
+        led2=0;
+    }
+    else if(led3==1){
+        //reverse        
+        left.speed(-speed);  
+        led3 =0;
+    }
+    
     if(tm.read()>.5)
     {
-      led1=!led1; //Show that we are alive
+      led4=!led4; //Show that we are alive
       tm.start();
     }
   }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Motordriver.lib	Thu Nov 03 21:45:57 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/littlexc/code/Motordriver/#3110b9209d3c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/NetServicesSource.lib	Thu Nov 03 21:45:57 2016 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/donatien/code/NetServicesSource/#da4498f591ee