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.
Diff: main.cpp
- Revision:
- 0:57862c82a696
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Thu Oct 22 02:08:35 2020 +0000
@@ -0,0 +1,82 @@
+#include "mbed.h"
+#include "TextLCD.h"
+
+TextLCD lcd(PTE20,PTE21,PTE22,PTE23,PTE29,PTE30, TextLCD::LCD16x2);// Rs, E, d4, d5, d6, d7, RW=GND
+
+
+
+AnalogIn AN0(PTB0);
+PwmOut l1(PTC2),l2(PTB3);
+DigitalIn pulsador1(PTC1),pulsador2(PTB1);
+void velocidad(int a,float ad);
+float valor_adc;
+int main() {
+ lcd.locate(0,0);
+ lcd.printf("seleccione la ");
+ lcd.locate(0,1);
+ lcd.printf("direccion");
+ l1.period(0.001f);//el periodo del pwm
+ l2.period(0.001f);
+ velocidad(0,0);//inicio el motor este no se movliza hasta que se le indique un sentidio
+ int selec=0;
+ while(1){
+ valor_adc=AN0;
+
+
+ lcd.locate(0,1);
+
+ if((pulsador1==1)&&(pulsador2==0)){
+ selec=1;
+
+ lcd.cls();
+ lcd.locate(0,0);
+ lcd.printf("IZQUIERDA");
+ wait(0.050);
+ }
+ if((pulsador1==0)&&(pulsador2==1)){
+ selec=2;
+
+ lcd.cls();
+ lcd.locate(0,0);
+ lcd.printf("derecha");
+ wait(0.050);
+ }
+ if((pulsador1==0)&&(pulsador2==0)){
+ selec=0;
+ lcd.cls();
+ lcd.locate(0,0);
+ lcd.printf("seleccione la ");
+ lcd.locate(0,1);
+ lcd.printf("direccion");
+ wait(0.050);
+
+
+ }
+ velocidad(selec,valor_adc);
+
+}
+}
+
+void velocidad(int a,float ad){
+ switch (a){
+ case 0:
+ l1=0;
+ l2=0;
+ break;
+ case 1:
+ l1.write(ad);
+ l2=0;
+ break;
+ case 2:
+ l2.write(ad);
+ l1=0;
+ break;
+
+ }
+
+
+ // 4 second period
+
+ }
+
+