TAREA 1 PROCESADORES

Dependencies:   Debounced TextLCD1 mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "DebouncedIn.h"
00003 #include "TextLCD1.h"
00004 int C1=0x0e;
00005 int i,k,j,n;
00006 int x=1;
00007 int px=3,py=0;
00008 int B1,B2;
00009 
00010 int main() {
00011 TextLCD lcd(PTB10, PTB11, PTE2, PTE3, PTE4, PTE5) ;// declaración de los puertos del lcd
00012 DebouncedIn b1(PTC16); //cambio de posición  
00013 DebouncedIn b2(PTC13);// aumento,
00014 DebouncedIn b3(PTC12);// disminuye
00015 lcd.printf("TAREA1:Proc"); // IMPRIMIR 
00016 wait(1); // espera 1 segundo
00017 lcd.cls();      // borra lcd
00018 lcd.writeCommand(C1); // escribe el comando C1
00019         // Localiza y escribe los titulos Sp,Kp,Ki,Kd en la patalla
00020 lcd.locate(0,0);
00021 lcd.printf("Sp:%d", b1.read());
00022 lcd.locate(8,0);
00023 lcd.printf("Kp:%d",b1.read());
00024 lcd.locate(0,1);
00025 lcd.printf("Ki:%d",b1.read());
00026 lcd.locate(8,1);
00027 lcd.printf("Kd:%d",b1.read());
00028         // Ciclo infinito
00029 while (1)
00030 {
00031 if(b2.falling()){
00032     x=x+1;
00033   
00034 }
00035 //condicionales para ubicación en pantalla
00036 if(x==1){
00037     px=3;
00038     py=0;
00039     
00040 }
00041 if(x==2)
00042 {
00043     px=11;
00044     py=0;
00045 }
00046 
00047 if(x==3){
00048     px=3;
00049     py=1;
00050 }
00051 if(x==4){
00052     px=11;
00053     py=1;
00054 }
00055 if(x>4){
00056     //px=0;
00057     //py=0;
00058     x=1;
00059 }
00060 //condicional para contador ascendente y imprimir
00061 
00062 if(px==3 && py==0){
00063 if(b1.falling()){
00064 i=i+1;
00065 }
00066 if(b3.falling()){
00067 i=i-1;
00068 }
00069 if(i<0){
00070 i=0;
00071 }
00072 lcd.locate(px,py);
00073 lcd.printf("%d",i);
00074 
00075 }
00076 
00077 if(px==11 && py==0){
00078 if(b1.falling()){
00079 k=k+1;
00080 }
00081 if(b3.falling()){
00082 k=k-1;
00083 }
00084 if(k<0){
00085 k=0;
00086 }
00087 lcd.locate(px,py);
00088 lcd.printf("%d",k);
00089 }
00090 
00091 if(px==3 && py==1){
00092 if(b1.falling()){
00093 j=j+1;
00094 }
00095 if(b3.falling()){
00096 j=j-1;
00097 }
00098 if(j<0){
00099 j=0;
00100 }
00101 lcd.locate(px,py);
00102 lcd.printf("%d",j);
00103 }
00104 if(px==11 && py==1){
00105 if(b1.falling()){
00106 n=n+1;
00107 }
00108 if(b3.falling()){
00109 n=n-1;
00110 }
00111 if(n<0){
00112 n=0;
00113 }
00114 lcd.locate(px,py);
00115 lcd.printf("%d",n);
00116 }
00117 //localizar en px,py y imprimir el valor de i
00118 //lcd.locate(px,py);
00119 //lcd.printf("%d",i);
00120 /*
00121 if(px==3 && py==0){
00122 
00123 }*/
00124 
00125 }
00126 }
00127 
00128 
00129 
00130