void main()
{
        int i,j,k,l;
        int count=0;
        char c;
        ENTER=1;
        EXIT=1;
  TRISD = 0xFF; // PORTD as input
 Lcd_Init(); // Initialize LCD
 Lcd_Cmd(_LCD_CLEAR); // Clear display
 Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
  Lcd_Out(1,1,"WELCOME:");//Write text'Hello World' in first row
  c=toChar(count);
   Lcd_chr(2,1,c);
 while(1)
{
 if(ENTER == 1)
 {
   Lcd_Cmd(_LCD_CLEAR);
   Lcd_Out(1,1,"WELCOME");
   count++;
     if(count == 999)
     count=0;
     Delay(500);
 }
  if(EXIT == 1)
  {
   Lcd_Cmd(_LCD_CLEAR);
   Lcd_Out(1,1,"THANKS");
   count--;
if(count == -1)
count=0;
Delay(500);
}
    i=count;
    j=i%10;
    k=i/10;
    l=i/100;
    k=k-l*10;
    c=toChar(j);
    Lcd_chr(2,3,c);
    c=toChar(k);
    Lcd_chr(2,2,c);
    c=toChar(l);
    Lcd_chr(2,1,c);
    }
    }
Beispiel #2
0
unsigned short obtenerNumero (unsigned short numeroMax) {
  unsigned short dig,numero,kp;
  volverObtenerNumero:
  dig = 0;
  numero=0;
  Lcd_chr(2, 5, ' '); Lcd_chr(2, 4, ' '); Lcd_chr(2, 3, ' '); Lcd_chr(2, 2, ' '); Lcd_chr(2, 1, ' ');
  
  leerNumero:
  do {
    kp = Keypad_Key_Click();             // Store key code in kp variable
    if (UART1_Data_Ready()){
      kp = UART1_Read();
      goto    bluetooth4;
    }
  }while (!kp);
  kp = teclado(kp);
  
  bluetooth4:
  if(kp == 'A' || kp== 'B' || kp == 'C' ||kp == 'D'){
    goto leerNumero;
  }else if (kp>=48 && kp<=57) {
    dig++;
    Lcd_chr_Cp(kp);
    numero = (kp-48)+(10*numero);
  }
  
  if(kp == '#'){
    goto volverObtenerNumero;
  }else if (kp == '*' ){
    Lcd_Chr (2,6,'G'); Lcd_Chr (2,7,'u'); Lcd_Chr (2,8,'a'); Lcd_Chr (2,9,'r');Lcd_Chr (2,10,'d');Lcd_Chr (2,11,'a'); Lcd_Chr (2,12,'d'); Lcd_Chr (2,13,'o');
    delay();
  }else if (numero >= numeroMax){
    //Lcd_Cmd(_LCD_CLEAR);
    Lcd_chr(2, 1,'M'); Lcd_chr(2, 2,'a'); Lcd_chr(2, 3,'x'); Lcd_chr(2, 5,'t');
    delay();
    delay();
    goto volverObtenerNumero;
  }else{
      goto leerNumero;
   }

   return (numero);
}
Beispiel #3
0
 /* 
    Nombre: qtama
    Descripcion: establece el tamaño de la porcion de comida servida.
    Parametros: ninguno
    Retorna: entero sin signo
 */
unsigned short qtama () {
 unsigned short kp;
  qtama:

   do {
      kp = Keypad_Key_Click();             // Store key code in kp variable
      if (UART1_Data_Ready()){
         kp = UART1_Read();
         goto    bluetooth1;
         }
      }while (!kp);
    kp = teclado(kp);
    
    bluetooth1:

    if(kp == 'A' ||kp== 'B' ||kp== 'C'||kp== 'D'){
          Lcd_chr(2, 5, kp);

    do {
      kp = Keypad_Key_Click();             // Store key code in kp variable
      if (UART1_Data_Ready()){
         kp = UART1_Read();
         goto    bluetooth2;
         }
      }while (!kp);
      
    kp = teclado(kp);
    bluetooth2:
    
    if(kp == '#'){
    goto qtama;
    }
   }
  else {
  goto qtama;
  }
  return (kp);
 }
Beispiel #4
0
unsigned short qtama () {
  unsigned short kp;
  qtama:
  
    do {
      kp = Keypad_Key_Click();
      if (UART1_Data_Ready()){
         kp = UART1_Read();
         goto    bluetooth1;
         }
    }while (!kp);
    kp = teclado(kp);
   
    bluetooth1:
    if(kp == 'A' ||kp== 'B' ||kp== 'C'||kp== 'D'){
      Lcd_chr(2, 4, kp);
      do {
        kp = Keypad_Key_Click();             // Store key code in kp variable
        if (UART1_Data_Ready()){
          kp = UART1_Read();
          goto    bluetooth2;
        }
      }while (!kp);
      kp = teclado(kp);
      
      bluetooth2:
      if(kp == '#'){
        goto qtama;
      }
      if(kp == '*'){
        Lcd_Chr (2,6,'G'); Lcd_Chr (2,7,'u'); Lcd_Chr (2,8,'a'); Lcd_Chr (2,9,'r');Lcd_Chr (2,10,'d');Lcd_Chr (2,11,'a'); Lcd_Chr (2,12,'d'); Lcd_Chr (2,13,'o');
      }
   }else {
     goto qtama;
   }
   return (kp);
 }