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: MotorMR001-004 mbed
main.cpp
00001 #include "mbed.h" 00002 #include "Motor.h" 00003 Serial pc (SERIAL_TX, SERIAL_RX); 00004 Motor m1(D10, D8, D9); //pwm (E1), fwd (1A), rev (1B) 00005 Motor m2(D5, D6, D7); //pwm (E2), fwd (2A), rev (2B) 00006 RawSerial hc05(D8, D2); 00007 00008 int main() { 00009 char a; 00010 pc.baud(9600); // setto il baud rate della porta seriale pc 00011 hc05.baud(9600); // setto il baud rate della porta rawserial hc05 00012 while(1) { 00013 if(hc05.readable()) { // se e’¨ stato ricevuto un carattere 00014 a=hc05.getc(); // assegna il carattere ricevuto alla var a 00015 if (a=='v') { 00016 m1.speed(1); 00017 m2.speed(1); 00018 wait(1.5); 00019 } 00020 else if(a=='d'){ 00021 m1.speed(0.6); 00022 m2.speed(-0.6); 00023 wait(1); 00024 } 00025 else if(a=='s'){ 00026 m1.speed(-0.6); 00027 m2.speed(0.6); 00028 wait(1); 00029 } 00030 /*else if(a=='p'{ 00031 m1.speed(0); 00032 m2.speed(0); 00033 } */ 00034 } 00035 } 00036 }
Generated on Wed Aug 10 2022 09:55:39 by
1.7.2