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: DebouncedIn PID QEI SRF05 TextLCD mbed
Fork of SensoresUltrasonicosSRF05 by
Diff: main.cpp
- Revision:
- 1:a24d4814cc4a
- Parent:
- 0:92ceb941f65e
diff -r 92ceb941f65e -r a24d4814cc4a main.cpp
--- a/main.cpp Mon Oct 21 16:03:20 2013 +0000
+++ b/main.cpp Sat Apr 25 13:53:20 2015 +0000
@@ -1,49 +1,48 @@
-#include "mbed.h"
-
#include "mbed.h"
#include "SRF05.h"
- // Trigger Echo
-SRF05 srfIzquierdo(p11, p12);
-SRF05 srf2Derecho(p13, p14);
-SRF05 srf3Frontal(p15, p16);
-
+#include "QEI.h"
+#include "TextLCD.h"
+#include <math.h>
+#include "DebouncedIn.h"
-//motor Izquierdo , atras y adelante
-DigitalOut FernandoAdI(LED1);
-DigitalOut FernandoAtI(LED2);
-//motor derecho , atras y adelante
-DigitalOut FernandoAdD(LED3);
-DigitalOut FernandoAtD(LED4);
+SRF05 srf(PTD0, PTD5);
+TextLCD lcd(PTB10, PTB11, PTE2, PTE3, PTE4, PTE5); // rs, e, d4-d7
+QEI encoder (PTD7, PTD6, NC, 1);
+DebouncedIn Pulsador(PTA17);
+PwmOut myled(LED1);
+
+// Definición de comandos para LCD
+
+int C2=0x18; // desplaza izquierda
+int C3=0x1A; // desplaza derecha
+int C4=0x0C; // quito cursor bajo
+int C1=0x0F;
+float val;
-int main() {
- while(1) {
- printf("Distance = %.1f %.1f %.1f \n\r", srfIzquierdo.read(),srf2Derecho.read(),srf3Frontal.read());
- FernandoAdI=0;
- FernandoAtI=0;
- FernandoAdD=0;
- FernandoAtD=0;
-
- // Sensor Izquierdo
- if (srfIzquierdo.read()>15)//distancia de sensro mayor a 15
- {
- //motor Izquierdo
- FernandoAdI=1; //input 1
- FernandoAtI=0; //intput2
- //motor Derecho
- FernandoAdD=1; //input3
- FernandoAtD=0; //input 4
- }
- else
- {
- FernandoAdI=0;
- FernandoAtI=1;
- FernandoAdD=0;
- FernandoAtD=1;
- }
-
-
- }
-
- // wait(0.2);
+int main() {
+ lcd.cls();
+ lcd.locate(0,0);
+ lcd.printf("Bienvenido");
+ wait(1);
+ lcd.cls();
+ lcd.locate(0,0);
+ lcd.printf("Distancia");
+
+ // //Analog input from 0.0 to 3.3V
+ // controller.setInputLimits(0.0, 3.3);
+ // //Pwm output from 0.0 to 1.0
+ // controller.setOutputLimits(0.0, 1.0);
+ // //If there's a bias.
+ // controller.setBias(0.3);
+ // controller.setMode(AUTO_MODE);
+ // //We want the process variable to be 1.7V
+ // controller.setSetPoint(1.7);
+
+ while(1) {
+ lcd.locate(0,1);
+ lcd.printf("%.2f\n", srf.read());
+ myled=srf.read()*0.01;
+ wait_ms(100);
}
+ }
\ No newline at end of file
