hej

Dependencies:   mbed

main.cpp

Committer:
Risifutti
Date:
2014-04-05
Revision:
0:36611331980a

File content as of revision 0:36611331980a:

#include "mbed.h" 
#include "hack_motor.h" 
  
Serial pc(USBTX, USBRX); 
  
Wheel robot; 
  
main() 
    { 
        robot.init(); 
        char c; 
        pc.printf(" speed 1, 2 & 3, frem w, bagud s, venstre a & hoejre d"); 
          
        while (1) 
            { 
            c = pc.getc(); 
              
            switch (c) 
                {  
                    case 0x31: 
                        robot.speed = 1.0; 
                        pc.printf("1"); 
                        break; 
                          
                    case 0x32: 
                        robot.speed = 0.5; 
                        pc.printf("2"); 
                        break; 
                          
                    case 0x33:  
                        robot.speed = 0.25; 
                        pc.printf("3"); 
                        break; 
                          
                    case 0x77: 
                        robot.FW(); 
                        pc.printf("w"); 
                        break; 
                      
                    case 0x73: 
                        robot.BW(); 
                        pc.printf("s"); 
                        break; 
                          
                    case 0x61: 
                        robot.left();  
                        pc.printf("a"); 
                        break; 
                          
                    case 0x64: 
                        robot.right(); 
                        pc.printf("d"); 
                        break; 
                        
                    case 'n':
                        robot.open();
                        pc.printf("n");
                        break;
                        
                        case 'm':
                        robot.close();
                        pc.printf("m");
                        break;
                        
                        case 'h':
                        robot.hejs();
                        pc.printf("h");
                        break;
                        
                        case 'b':
                        robot.saenk();
                        pc.printf("b");
                        break;
                      
                    default : 
                        robot.stop(); 
                        break; 
                    } 
                } 
    }