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: mbed TextLCD Keypad
Revision 0:c443bef46896, committed 2020-03-09
- Comitter:
- 20161773009
- Date:
- Mon Mar 09 07:29:01 2020 +0000
- Commit message:
- .
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Keypad.lib Mon Mar 09 07:29:01 2020 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/grantphillips/code/Keypad/#4bbd88022a6f
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TextLCD.lib Mon Mar 09 07:29:01 2020 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/simon/code/TextLCD/#308d188a2d3a
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Mon Mar 09 07:29:01 2020 +0000
@@ -0,0 +1,265 @@
+#include "mbed.h"
+#include "TextLCD.h"
+#include "Keypad.h"
+
+PwmOut Md(PTA2)PwmOut Md(PTD4);
+PwmOut Mi(PTA1);
+PwmOut Md(PTD4);
+PwmOut Mi(PTA12);
+TextLCD lcd(PTB8,PTB9,PTB10,PTB11,PTE2,PTE3,TextLCD::LCD16x2);
+Keypad teclado(PTC4,PTC3,PTC0,PTC7,PTC11,PTC10,PTC6,PTC5);
+int d=0, i=0;
+char key; //char porque se recibe de teclado caracteres
+int released=1; //entero que nos dice cuando hay pulso en el teclado
+
+void MotorDerecha(){
+
+ key = teclado.ReadKey();
+
+ /* if(key == '\0')
+ released = 1;
+
+ if((key != '\0')&&(released == 1) ){*/
+ if(key=='A'){
+ lcd.cls();
+ lcd.locate(0,0);
+ lcd.printf("Motor Derecha");
+ d=1;
+ }
+ //while (d=1){
+ /*if(key==65){
+ lcd.cls();
+ lcd.locate(0,0);
+ lcd.printf("Motor Derecha");
+
+ }
+ */
+ if(d==1 and key=='0'){
+ lcd.cls();
+ lcd.locate(0,0);
+ lcd.printf("Motor Detenido");
+ Md=0;
+ Mi=0;
+ i=0;
+ }
+
+ else if(d==1 and key=='1'){
+ lcd.cls();
+ lcd.locate(0,0);
+ lcd.printf("Motor Derecha");
+ lcd.locate(0,1);
+ lcd.printf("Velocidad 1");
+ Md=0.2;
+ Mi=0;
+ i=0;
+ }
+
+ else if(d==1 and key=='2'){
+ lcd.cls();
+ lcd.locate(0,0);
+ lcd.printf("Motor Derecha");
+ lcd.locate(0,1);
+ lcd.printf("Velocidad 2");
+ Md=0.4;
+ Mi=0;
+ i=0;
+ }
+
+ else if(d==1 and key=='3'){
+ lcd.cls();
+ lcd.locate(0,0);
+ lcd.printf("Motor Derecha");
+ lcd.locate(0,1);
+ lcd.printf("Velocidad 3");
+ Md=0.6;
+ Mi=0;
+ i=0;
+ }
+ else if(d==1 and key=='4'){
+ lcd.cls();
+ lcd.locate(0,0);
+ lcd.printf("Motor Derecha");
+ lcd.locate(0,1);
+ lcd.printf("Velocidad 4");
+ Md=0.6;
+ Mi=0;
+ i=0;
+ }
+
+ else if(d==1 and key=='5'){
+ lcd.cls();
+ lcd.locate(0,0);
+ lcd.printf("Motor Derecha");
+ lcd.locate(0,1);
+ lcd.printf("Velocidad 5");
+ Md=0.8;
+ Mi=0;
+ i=0;
+ }
+
+ else if(d==1 and key=='6'){
+ lcd.cls();
+ lcd.locate(0,0);
+ lcd.printf("Motor Derecha");
+ lcd.locate(0,1);
+ lcd.printf("Velocidad 6");
+ Md=1;
+ Mi=0;
+ i=0;
+ }
+
+ else if(d==1 and key=='D'){
+ lcd.cls();
+ lcd.locate(0,0);
+ lcd.printf("Cambio de");
+ lcd.locate(0,1);
+ lcd.printf("Direccion");
+ Md=0;
+ Mi=0;
+ d=0;
+ i=0;
+
+ }
+
+ //released=0;
+
+
+
+ //}
+}
+
+void MotorIzquierda(){
+
+ key = teclado.ReadKey();
+
+ /*if(key == '\0')
+ released = 1;
+
+ if((key != '\0')&&(released == 1) ){*/
+ if(key=='B'){
+ lcd.cls();
+ lcd.locate(0,0);
+ lcd.printf("Motor Izquierda");
+ i=1;
+ }
+ //while (d=1){
+ /*if(key==65){
+ lcd.cls();
+ lcd.locate(0,0);
+ lcd.printf("Motor Izquierda");
+
+ }
+ */
+ if(i==1 and key==48){
+ lcd.cls();
+ lcd.locate(0,0);
+ lcd.printf("Motor Detenido");
+ Md=0;
+ Mi=0;
+ }
+
+ else if(i==1 and key==49){
+ lcd.cls();
+ lcd.locate(0,0);
+ lcd.printf("Motor Izquierda");
+ lcd.locate(0,1);
+ lcd.printf("Velocidad 1");
+ Mi=0.2;
+ Md=0;
+ }
+
+ else if(i==1 and key==50){
+ lcd.cls();
+ lcd.locate(0,0);
+ lcd.printf("Motor Izquierda");
+ lcd.locate(0,1);
+ lcd.printf("Velocidad 2");
+ Mi=0.4;
+ Md=0;
+ }
+
+ else if(i==1 and key==51){
+ lcd.cls();
+ lcd.locate(0,0);
+ lcd.printf("Motor Izquierda");
+ lcd.locate(0,1);
+ lcd.printf("Velocidad 3");
+ Mi=0.6;
+ Md=0;
+ }
+ else if(i==1 and key==52){
+ lcd.cls();
+ lcd.locate(0,0);
+ lcd.printf("Motor Izquierda");
+ lcd.locate(0,1);
+ lcd.printf("Velocidad 4");
+ Mi=0.6;
+ Md=0;
+ }
+
+ else if(i==1 and key==53){
+ lcd.cls();
+ lcd.locate(0,0);
+ lcd.printf("Motor Izquierda");
+ lcd.locate(0,1);
+ lcd.printf("Velocidad 5");
+ Mi=0.8;
+ Md=0;
+ }
+
+ else if(i==1 and key==54){
+ lcd.cls();
+ lcd.locate(0,0);
+ lcd.printf("Motor Izquierda");
+ lcd.locate(0,1);
+ lcd.printf("Velocidad 6");
+ Mi=1;
+ Md=0;
+ }
+
+ else if(i==1 and key==68){
+ lcd.cls();
+ lcd.locate(0,0);
+ lcd.printf("Cambio de");
+ lcd.locate(0,1);
+ lcd.printf("Direccion");
+ Md=0;
+ Mi=0;
+ i=0;
+
+ }
+
+ //released=0;
+
+// }
+
+ //}
+}
+int main() {
+ lcd.cls();
+ lcd.locate(0,0);
+ lcd.printf("Bienvenido");
+ lcd.locate(0,1);
+ lcd.printf("Grupo!");
+ wait(2);
+ lcd.cls();
+ lcd.locate(0,0);
+ lcd.printf("Integrantes:");
+ wait(2);
+ lcd.cls();
+ lcd.locate(0,0);
+ lcd.printf("Maikol Zarate");
+ lcd.locate(0,1);
+ lcd.printf("Brandon Bernal");
+ wait(2);
+ lcd.cls();
+
+
+ while(1){
+ MotorDerecha();
+ MotorIzquierda();
+}
+}
+
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Mon Mar 09 07:29:01 2020 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file