Advertisement
urksiful

LCD Turn On/Off Motor

Dec 12th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.45 KB | None | 0 0
  1. #include <xc.h>
  2. #define _XTAL_FREQ 8000000
  3. #include "flex_lcd.h"
  4. #include <stdio.h>
  5. // CONFIG
  6. #pragma config FOSC = XT        // Oscillator Selection bits (XT oscillator)
  7. #pragma config WDTE = OFF       // Watchdog Timer (WDT disabled)
  8. #pragma config PWRTE = OFF      // Power-up Timer Enable bit (Power-up Timer is disabled)
  9. #pragma config CP = OFF         // Code Protection bit (Code protection disabled)
  10.  
  11.  
  12.  
  13. void main(void) {
  14.    
  15.        
  16.     TRISA =12; //12=01100
  17.     PORTA =0; //LIMPIAR RESIDUOS
  18.     int a=0;
  19.        
  20.    
  21.     if(PORTAbits.RA2==1 || PORTAbits.RA3==1){
  22.  
  23.     }else{
  24.              Lcd_Init();
  25.              Lcd_Cmd(LCD_CLEAR);
  26.              Lcd_Cmd(LCD_CURSOR_OFF);
  27.              Lcd_Out(1,1,"sistemas77C");  
  28.              a2=1;
  29.              a=0;
  30.        }
  31.    
  32.    
  33.     if(PORTAbits.RA2==1){
  34.         if(a==0){
  35.     Lcd_Cmd(LCD_CLEAR); //limpiar lcd
  36.     Lcd_Cmd(LCD_CURSOR_OFF); //apagar cursor  
  37.     Lcd_Out(1,1,"sentido de motor");
  38.     Lcd_Out(2,2,"izquierda.");            
  39.         }
  40.  
  41.         a=1;
  42.     PORTAbits.RA0=1;
  43.     PORTAbits.RA1=0;
  44.     __delay_ms(1000);
  45.  
  46.     }else if(PORTAbits.RA3==1){
  47.         if(a==0){
  48.     Lcd_Cmd(LCD_CLEAR); //limpiar lcd
  49.     Lcd_Cmd(LCD_CURSOR_OFF); //apagar cursor  
  50.     Lcd_Out(1,1,"sentido de motor");
  51.     Lcd_Out(2,2,"derecha");        
  52.         }
  53.    
  54.        
  55.         a=1;
  56.     PORTAbits.RA1=1;
  57.     PORTAbits.RA0=0;
  58.      __delay_ms(1000);
  59.  
  60.     }
  61.    
  62.     return;
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement