Exemplo n.º 1
0
void Proceso(void){
 // Lectura del Voutput del sensor LM35
 // Mostrando Voutput y su conversion a °C
 char val[15];
 float volts;
 float grados;
 char centigrados[15];
 
 adc_value = ADC1_Get_Sample(10);
 grados = adc_value/cuentas;
 FloatToStr(grados,centigrados);
 UART1_Write_Text(centigrados);
 UART1_Write(13);
 UART1_Write(10);
 Lcd_Out(1, 1, centigrados);
 Lcd_Out(1, 8, "\xDFc");
 
 volts = adc_value;
 FloatToStr(volts,val);
 Lcd_Out(2, 15, "V");
 Lcd_Out(2, 1, val);
 delay(0xFFFFF);
 Lcd_Cmd(_LCD_CLEAR);
 
if (UART1_Data_Ready()) {     // If data is received
 uart_rd = UART1_Read();     // read the received data
 if (uart_rd == '1'){
  LAMPARA = ~LAMPARA;
 }
 else if (uart_rd == '2')
 {
  VENTILADOR = ~VENTILADOR;
 }
}
}
Exemplo n.º 2
0
void main(){

  Lcd_Init();                        // Initialize Lcd

  Lcd_Cmd(_LCD_CLEAR);               // Clear display
  Lcd_Cmd(_LCD_CURSOR_OFF);          // Cursor off
  Lcd_Out(1,6,txt3);                 // Write text in first row

  Lcd_Out(2,6,txt4);                 // Write text in second row
  Delay_ms(2000);
  Lcd_Cmd(_LCD_CLEAR);               // Clear display

  Lcd_Out(1,1,txt1);                 // Write text in first row
  Lcd_Out(2,5,txt2);                 // Write text in second row

  Delay_ms(2000);

  // Moving text
  for(i=0; i<4; i++) {               // Move text to the right 4 times
    Lcd_Cmd(_LCD_SHIFT_RIGHT);
    Move_Delay();
  }

  while(1) {                         // Endless loop
    for(i=0; i<8; i++) {             // Move text to the left 7 times
      Lcd_Cmd(_LCD_SHIFT_LEFT);
      Move_Delay();
    }

    for(i=0; i<8; i++) {             // Move text to the right 7 times
      Lcd_Cmd(_LCD_SHIFT_RIGHT);
      Move_Delay();
    }
  }
}
Exemplo n.º 3
0
void main() {
     unsigned char write = 'A';
     unsigned char read;
     
     char buffer[10];
     
     TWI_Init(100000);
     Lcd_Init();
     
     Write24C64_Byte(DEV24C64_ADDR, 0x00, write);
     read = Read24C64_Byte(DEV24C64_ADDR, 0x00);
     
     IntToHex(read, buffer);
     Lcd_Out(1, 1, buffer);
     
     while (1);
     
     if( write == read ) {
         Lcd_Out(1, 1, "Successfully written");
     } else {
         Lcd_Out(1, 1, "Data writing failed");
     }
     

     while (1) {

     }
}
void main()
{
  char txt[7];
  Lcd_Init();
  Lcd_Cmd(_LCD_CLEAR);                 // Clear display
  Lcd_Cmd(_LCD_CURSOR_OFF);            // Cursor off

  TRISB = 0b00010000;
  INTCON.GIE = 1;                      //Global Interrupt Enable
  INTCON.RBIF = 0;                     //Clear PORTB On-Change Interrupt Flag
  INTCON.RBIE = 1;                     //Enable PORTB On-Change Interrupt

  Lcd_Out(1,1,"Developed By");
  Lcd_Out(2,1,"CELAB");

  Delay_ms(3000);
  Lcd_Cmd(_LCD_CLEAR);

  T1CON = 0x10;                        //Initializing Timer Module

   while(1)
  {
    TMR1H = 0;                  //Sets the Initial Value of Timer
    TMR1L = 0;                  //Sets the Initial Value of Timer

    PORTB.F0 = 1;               //TRIGGER HIGH
    Delay_us(10);               //10uS Delay
    PORTB.F0 = 0;               //TRIGGER LOW

    while(!PORTB.F4);           //Waiting for Echo
    T1CON.F0 = 1;               //Timer Starts
    while(PORTB.F4);            //Waiting for Echo goes LOW
    T1CON.F0 = 0;               //Timer Stops

    a = (TMR1L | (TMR1H<<8));   //Reads Timer Value
    a = a/58.82;                //Converts Time to Distance
    a = a + 1;                  //Distance Calibration\
    if(a>=2 && a<=400)          //Check whether the result is valid or not
    {
      IntToStr(a,txt);
      Ltrim(txt);
      Lcd_Cmd(_LCD_CLEAR);
      Lcd_Out(1,1,"Distance = ");
      Lcd_Out(1,12,txt);
      Lcd_Out(1,15,"cm");
    }
    Delay_ms(400);
  }
}
Exemplo n.º 5
0
void displayEditFeed1(int mode, int index, int x, int y)
{
    Time *t;
    t = &feedTime[index];
    temp_text[0] = index + 1 + '0';
    temp_text[1] = ':';
    temp_text[2] = 0;

    clearLine(x);
    Lcd_Out(x, y, title);
    Lcd_Out(x, y + TITLE_LENGTH, temp_text);
    Lcd_Out(x, y + TITLE_LENGTH + 3, timeStr(t->hh));
    Lcd_Out(x, y + TITLE_LENGTH + 5, column);
    Lcd_Out(x, y + TITLE_LENGTH + 6, timeStr(t->mn));
}
Exemplo n.º 6
0
void Display_Time_Core(unsigned char *sec, unsigned char *min, unsigned char *hr, unsigned char *wd, unsigned char *day, unsigned char *mn, unsigned char *year) {
	// for some other testing
	unsigned char txtSec[5] = "";
	unsigned char txtMin[5] = "";
	unsigned char txtHour[5] = "";
	unsigned char txtWd[5] = "";
	unsigned char txtDay[5] = "";
	unsigned char txtMn[5] = "";
	unsigned char txtYear[5] = "";
	unsigned char txtDisplayRow1[16] = "";
	unsigned char txtDisplayRow2[16] = "";

	ShortToStr(*sec, txtSec);
	ShortToStr(*min, txtMin);
	ShortToStr(*hr, txtHour);
	ShortToStr(*wd, txtWd);
	ShortToStr(*day, txtDay);
	ShortToStr(*mn, txtMn);
	ShortToStr(*year, txtYear);

	MakeLastTwoChars(txtSec);
	MakeLastTwoChars(txtMin);
	MakeLastTwoChars(txtHour);
	MakeLastTwoChars(txtWd);
	MakeLastTwoChars(txtDay);
	MakeLastTwoChars(txtMn);
	MakeLastTwoChars(txtYear);

	strcat(txtDisplayRow1, "DATE:");
	strcat(txtDisplayRow1, txtMn);
	strcat(txtDisplayRow1, "/");
	strcat(txtDisplayRow1, txtDay);
	strcat(txtDisplayRow1, "/");
	strcat(txtDisplayRow1, txtYear);
	strcat(txtDisplayRow1, ":");
	strcat(txtDisplayRow1, txtWd);

	strcat(txtDisplayRow2, "TIME:");
	strcat(txtDisplayRow2, txtHour);
	strcat(txtDisplayRow2, ":");
	strcat(txtDisplayRow2, txtMin);
	strcat(txtDisplayRow2, ":");
	strcat(txtDisplayRow2, txtSec);

	Lcd_Cmd(_LCD_CLEAR);
	Lcd_Out(1,1,txtDisplayRow1);
	Lcd_Out(2,1,txtDisplayRow2);
}
Exemplo n.º 7
0
void main(){
ADCON1 = 0b00001110;             // HABILITA CANAL AN0 E AN1
TRISA.RA0 = 1;
Lcd_Init ();                     // START LCD
Lcd_Cmd(_Lcd_Clear);             // CLEAR LCD
Lcd_Cmd(_LCD_CURSOR_OFF);        // TURN OFF LCD CURSOR
ADC_Init();
while(1){
adc_rd = ADC_Read(0);                        // GET ADC VALUE FROM 1ST CHANNEL
EEPROM_Write(0x08, adc_rd);       //ESCREVE "adc_rd" NA POSICAO 0x08 DA EEPROM
IntToStr(adc_rd, adcprint);                            // CONVERSION TO STRING
Lcd_out(1,1,"COUNTS..: ");
Lcd_Out_Cp(adcprint);                     // PRINTS ADC STEPS IN LCD FIRST ROW
if (diff != adc_rd){
BarSegmentNum = adc_rd /(1023 / 16);
                                    // CALCULATE NUMBERS OF BAR GRAPH SEGMENTS
Lcd_out(2,1,"                ");    // CLEARS LCD SECOND ROW
for (i = 0; i < BarSegmentNum; i++){
                               // LOOP TO PRINT EACH BAR SEGMENT IN SECOND ROW
CustomChar(2, i+1);}}           // PRINT CUSTOM CHARACTER FOR BARGRAPH SEGMENT
Delay_ms(750);                                        // STABILIZE LCD DISPLAY
diff = adc_rd;
// LCD SHOWS EEPROM VALUE
ADCeer = EEPROM_Read(0x08);                     // LE A POSICAO 0x08 DA EEPROM
ShortToStr (ADCeer, ADCeerSTR);
//Lcd_Cmd(_LCD_CLEAR);                                  // LIMPA A TELA DO LCD
Lcd_Out(2, 1, ADCeerSTR);
Delay_ms(2000);
Lcd_Cmd(_LCD_CLEAR);                                    // LIMPA A TELA DO LCD
}                                                                 // END WHILE
}                                                                  // END MAIN
Exemplo n.º 8
0
void moverEnAutomatico(){
uart_rd_temp = ' ';
bandera_automatico = 1;       /* Con esta bandera se valida en la interrupcion que hacer cuando ocurre un choque. */
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(2,6,txtAutomatic);
/* Inicio de movimiento en automatico hacia adelante. */
 RC1_bit = 1;
 RC2_bit = 1;
 RC5_bit = 0;
 RC4_bit = 0;
 cargarDato();
 while (uart_rd_temp != 'e') { /* Si se le envía e se sale de modo automatico. */
   waitSignal();
   cargarDato();

   /* Al salir de modo automatico paramos los motores.*/
   if(uart_rd_temp == 'e')
     {
       RC1_bit = 0;
       RC2_bit = 0;
       RC5_bit = 0;
       RC4_bit = 0;
     }

 }
 pararVehiculo();
 bandera_automatico = 0;       /* al enviar e se sale de modo automatico.*/
}
Exemplo n.º 9
0
void Proceso(void){
 char val[10];
 float voltsFotoA;
 voltsFotoA = FotoA();
 FloatToStr(voltsFotoA,val);
 Lcd_Out(1, 1, val);
}
Exemplo n.º 10
0
void main()
{
int i;



trisb=0;
portb=0;
     Lcd_Init();                        // Initialize LCD

UART1_Init(9600); // Initialize UART module at 9600 bps
Delay_ms(100); // Wait for UART module to stabilize
while (1)       // Endless loop
{
if (UART1_Data_Ready())    // If data is received,
{
 for(i=0;i<100;i++)
 {
 uart_rd[i]= UART1_Read();
}
for(i=0;i<100;i++)
{
  Lcd_Cmd(_LCD_CLEAR);               // Clear display
  Lcd_Cmd(_LCD_CURSOR_OFF);          // Cursor off
  Lcd_Out(1,1,uart_rd[i]);
  delay_ms(10000);
}
}
}
}
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);
    }
    }
void main() {            // FUNCAO PRINCIPAL: MAIN
ADCON1 = 0x07;           // CONFIGURA ENTRADAS AN COMO E/S DIGITAIS
CMCON = 7;               // DESLIGA COMPARADORES
// CONFIGURACOES E/S E ESTADOS INICIAIS [BINARIO]
   TRISA = 0b00000000;            PORTA = 0b00000000;
   TRISB = 0b00000110;         // PORTB = 0b00000000;
   TRISC = 0b00000000;            PORTC = 0b00000000;
// ESTADOS INICIAIS DOS ACESSORIOS
BUZZER = 1;
// MENSAGEM INICIAL NO LCD
Lcd_Init();                                 // INICIA O LCD
Lcd_Cmd(_LCD_CLEAR);                        // LIMPA A TELA DO LCD
Lcd_Cmd(_LCD_CURSOR_OFF);                   // DESLIGA O CURSOR
Lcd_Out(1, 1, msg_2); 
Lcd_Out(2, 1, msg_1);
Delay_ms(1500);
Lcd_Cmd(_LCD_CLEAR);                        // LIMPA A TELA DO LCD
while (1) {
if (!INT2) {
BUZZER = 0; Delay_ms(15); BUZZER = 1; Delay_ms(50);
BUZZER = 0; Delay_ms(15); BUZZER = 1;       // SIRENE SOA DUAS VEZES CURTAS
// EEPROM_Write(unsigned short address, unsigned short data);
EEPROM_Write(0x08, 'K');               //ESCREVE "K" NA POSICAO 0x08 DA EEPROM
Lcd_Cmd(_LCD_CLEAR);                        // LIMPA A TELA DO LCD
Lcd_Out(1, 1, msg_1);
Lcd_Out(2, 1, msg_3);   
Delay_ms(1000);
Lcd_Cmd(_LCD_CLEAR);                        // LIMPA A TELA DO LCD
} else if (!INT1) {
BUZZER = 0; Delay_ms(15); BUZZER = 1;       // SIRENE SOA UMA VEZ CURTA
// EEPROM_Read(unsigned short address);
INFO = EEPROM_Read(0x08);                   // LE A POSICAO 0x08 DA EEPROM
ShortToStr (INFO, INFO_s);
Lcd_Cmd(_LCD_CLEAR);                        // LIMPA A TELA DO LCD
Lcd_Out(1, 1, msg_1);
Lcd_Out(2, 1, msg_4);   
Delay_ms(1000);
Lcd_Cmd(_LCD_CLEAR);                        // LIMPA A TELA DO LCD
Lcd_Out(1,1,INFO_s);   
Lcd_Out_Cp(" = DECIMAL");      
Lcd_Cmd(_LCD_SECOND_ROW);
Lcd_Chr_Cp(0+INFO);    
Lcd_Out_Cp(" =  CHARACTER");   
Delay_ms(2500);
Lcd_Cmd(_LCD_CLEAR);}                       // LIMPA A TELA DO LCD
else {
Lcd_Out(1, 1, msg_5);                       
Lcd_Out(2, 1, msg_6);
}                                                                  // FIM ELSE
 }                                                               // FIM  WHILE
  }                                                                // FIM MAIN
Exemplo n.º 13
0
void Config_UART1(void){
 UART1_Init(9600);
 Delay_ms(100);
 /*UART1_Write_Text("Inicio");
 UART1_Write(13);
 UART1_Write(10);*/
 Lcd_Out(1, 1, "Inicia UART1");
 delay_ms(2000);
}
Exemplo n.º 14
0
void displayFeedTimes(int x, int y)
{
    Time *t;
    int i;
    t = &feedTime;

    clearLine(x);
    Lcd_Out(x, y, title);
    y += TITLE_LENGTH;

    for(i = 0; i < 2; i++, t++)
    {
      Lcd_Out(x, y, timeStr(t->hh));
      Lcd_Out(x, y + 2, column);
      Lcd_Out(x, y + 3, timeStr(t->mn));
      y += 6;
    }
}
Exemplo n.º 15
0
void Proceso2(void){
 char val2[10];
 float voltsFotoB;
 voltsFotoB = FotoB();
 FloatToStr(voltsFotoB,val2);
 Lcd_Out(2, 1, val2);
 delay(0xFFFFF);
 Lcd_Cmd(_LCD_CLEAR);
}
Exemplo n.º 16
0
unsigned short obtenerNumero (unsigned short numMax) {
  unsigned short dig, numero, kp;
  volverObtenerNumero:
  dig = 0;
  numero=0;
  
  leerNum:
  do {
      kp = Keypad_Key_Click();
      if (UART1_Data_Ready()){
        kp = UART1_Read();
        goto    bluetoothRead;
      }
    }while (!kp);
    kp = teclado(kp);
    
    bluetoothRead:
    if(kp == 'A' || kp== 'B' || kp == 'C' ||kp == 'D'){
      goto leerNum;
    }else if (kp != '#' && kp != '*'){
      dig++;
      numero =  numero*10  +  kp -48;
      //Lcd_Chr(2, 7+dig, kp);
    }
  
  //}while (numero > numMax && kp != '*'  && kp != '#');
  
  if(kp == '#'){               //si presiona numeral se borra el numero
    goto volverObtenerNumero;
  }else if (kp == '*' && numero > 0){
    //Lcd_Chr(2, 7, (numero+48));
    Lcd_Out(2, 1, "Valor guardado");
    delay();
  }else if (numero > numMax){
    Lcd_Cmd(_LCD_CLEAR);
    Lcd_Out(2, 1, "Se paso de valor maximo");
    delay();
    goto volverObtenerNumero;
  } else{
    goto leerNum;
  }

  return (numero);
}
Exemplo n.º 17
0
void main() {

  TRISA = 0b00000000; // set PORTA -> salidas
  TRISB = 0b01000000; // set PORTB -> salida menos el pin 6.
  ANSEL  = 0;              // Configure AN2 pin as analog
  ANSELH = 0;
  C1ON_bit = 0;                      // Disable comparators
  C2ON_bit = 0;
  INTCON = 0b10100000; // INTERRUPCION POR TIMER0 Y GIE ACTIVADOS.
  /* INTCON.T0IE = 1;                 /\* Activado interrupcion por timer0 *\/ */
  OPTION_REG = 0b10000111; //  TMR0 temporizado:  RBPU, TOCS= INTERNAL INSTRUCTION CLOCK= 0 PSA =0   1:256
  TRISC = 0b10000000;                          // PUERTOC COMO SALIDA exepto pin 7
  PORTC = 0;                          // LIMPIAR PUERTOC
  setupTimer1();
  Delay_us(10);                 /* wait for acquisition time*/
  Lcd_Init();                        // Initialize LCD

  /* Programa principal */
  Lcd_Out(2,0,txtDefault);                 // Write text in second row
  UART1_Init(9600);                         // initialize UART1 module
  Delay_ms(100);                  // Wait for UART module to stabilize
  moverEnAutomatico();
  while (1) {
    waitSignal();
    if (UART1_Data_Ready()) {     // If data is received,
      uart_rd = UART1_Read();     // leer el dato recibido del celular
      waitSignal();
      switch (uart_rd) {
      case 'A': {               /* Modo automático */
        Lcd_Out(2,6,txtAutomatic);
        moverEnAutomatico();
        break;
      }
      case 'M': {
        moverManual();
        break;
      }
      default:
        break;
      }
    }
  }
}
Exemplo n.º 18
0
void main(){
  ANSEL  = 0;                        // Configure AN pins as digital I/O
  ANSELH = 0;
  C1ON_bit = 0;                      // Disable comparators
  C2ON_bit = 0;
  TRISD=255;
  TRISA = 0;

  Lcd_Init();                        // Initialize LCD
  
  cont1 = 0;

  while(1){
  
  num = PORTD;
  
  switch(num){
  
  case 1:
       Lcd_Out(1,1, "Secuencia 1");
       PORTA = 255;
       Delay_ms(500);
       PORTA = 0;
       Delay_ms(500);
       break;
  case 2:
       Lcd_Out(1,1, "Secuencia 2");
       PORTA = 128;
       Delay_ms(500);
       PORTA = 0;
       Delay_ms(500);
       break;
  
  
  
  
  
  }
  
  }
}
Exemplo n.º 19
0
void displayEdited(int x, int y)
{
    if(mode == MODE_EDIT_MIN)
    {
        Lcd_Out(x, y, "min=");
        Lcd_Out(x, y+4, toStr(minTemp));
        Lcd_Out(x, y+8, "       ");
    }
    else if(mode == MODE_EDIT_MAX)
    {
        Lcd_Out(x, y, "max=");
        Lcd_Out(x, y+4, toStr(maxTemp));
        Lcd_Out(x, y+8, "       ");
    }
    else
    {
        Lcd_Out(x, y, "Lim  ");
        Lcd_Out(x, y+5, toStr(minTemp));
        Lcd_Out(x, y+9, " ");
        Lcd_Out(x, y+11, toStr(maxTemp));
    }
}
Exemplo n.º 20
0
void main() {
  char val[5];
  char val1[5];
  Conf_puertos();
  Lcd_Init();
  Lcd_Cmd(_LCD_CLEAR);
  Lcd_Cmd(_LCD_CURSOR_OFF);

  //LAMPARA = 1;
  current_duty = 3900;                        // initial value for current_duty
  pwm_period1 = PWM_TIM2_Init(50);
  PWM_TIM2_Set_Duty(current_duty,  _PWM_NON_INVERTED, _PWM_CHANNEL2);
  PWM_TIM2_Start(_PWM_CHANNEL2, &_GPIO_MODULE_TIM2_CH2_PA1);
  FloatToStr(pwm_period1,val);
  FloatToStr(current_duty,val1);
  Lcd_Out(1, 1, val);
  Lcd_Out(2, 3, val1);
  delay(0xFFFFF);
    while (1){
     //if(GPIOA_IDR.B0){
      //LAMPARA = ~LAMPARA;
      if(current_duty <=6850){
       char val1[5];
       Delay_ms(1);
       current_duty = current_duty - 15;       // increment current_duty
        if (current_duty < 1700 ) {      // if we increase current_duty greater then possible pwm_period1 value
           current_duty = 6850;                    // reset current_duty value to zero
        }
       PWM_TIM2_Set_Duty(current_duty,  _PWM_NON_INVERTED, _PWM_CHANNEL2); /// set newly acquired duty ratio
       PWM_TIM2_Start(_PWM_CHANNEL2, &_GPIO_MODULE_TIM2_CH2_PA1); //agregamos que haga el cambio cada vez presionado el boton
       FloatToStr(current_duty,val1);
       Lcd_Out(1, 1, val);
       Lcd_Out(2, 1, val1);
       //delay(0x1);
       Lcd_Cmd(_LCD_CLEAR);
      }
    Delay_ms(1);                 // slow down change pace a little
    }
}
Exemplo n.º 21
0
void main() {
    Lcd_Init();
    Foto_ADC_Init();
    Config_ptos();
    Lcd_Cmd(_LCD_CLEAR);               // Clear display
    Lcd_Out(1, 1, "9CM11-Volmetro");
    delay_ms(2000);
    Lcd_Cmd(_LCD_CLEAR);
    Lcd_Cmd(_LCD_CURSOR_OFF);
    while(1){
        Proceso();
        Proceso2();
    }
}
void main() {
     /*
       Lcd_Init() to initialize the library
     */
     Lcd_Init();
     
     /*
       In order to print a string on a specific
       row, colum, use the following function.
       
       first number is the line number.
       second number is the column number.
     */
     Lcd_Out(1, 1, "Jontropati.com");
     
     Delay_ms(1000);      // delay- 1 sec
     
     
     /*
       THis function append some new string from
       previous string position
     */
     Lcd_Out_CP(" !!!");

     Delay_ms(1000);    // delay 1 sec
     
     /*
       Clear the LCD display
     */
     Lcd_Cmd(_LCD_CLEAR);
     

     /*
       Below funciton, prints a charecter
       on specific line, column
     */
     Lcd_Chr(1, 1, 'A');
     
     Delay_ms(1000);
     
     /*
       This function appends a new charecter
       from previous position.
     */
     Lcd_Chr_CP('B');

     while (1) {

     }
}
Exemplo n.º 23
0
void main() {
 Lcd_Init();
 Config_ptos();
 Config_adc();
 Config_UART1();
 Lcd_Cmd(_LCD_CLEAR);
 Lcd_Out(1, 1, "9CM11-Termometro");
 delay_ms(2000);
 Lcd_Cmd(_LCD_CLEAR);
 Lcd_Cmd(_LCD_CURSOR_OFF);
 while(1){
  Proceso();
 }
}
Exemplo n.º 24
0
void main() {
ADCON1 = 0x07;           // CONFIGURA ENTRADAS AN COMO E/S DIGITAIS
CMCON = 7;               // DESLIGA COMPARADORES
// CONFIGURACOES E/S E ESTADOS INICIAIS [BINARIO]
   TRISA = 0b00000000;            PORTA = 0b00000000;
   TRISB = 0b00000110;            PORTB = 0b00000000;
   TRISC = 0b00000000;            PORTC = 0b00000000;
// TRISD = 0b00000000;            PORTD = 0b00000000;
// TRISE = 0b00000000;            PORTE = 0b00000000;

// ESTADOS INICIAIS DOS ACESSORIOS EM USO
BUZZER = 1;

// MENSAGEM INICIAL NO LCD
Lcd_Init();                                 // INICIA O LCD
Lcd_Cmd(_LCD_CLEAR);                        // LIMPA A TELA DO LCD
Lcd_Cmd(_LCD_CURSOR_OFF);                   // DESLIGA O CURSOR
Lcd_Out(1, 1, msg_1);
Lcd_Out(2, 1, msg_2);

while (1){
BUZZER = 0; Delay_ms(15); BUZZER = 1; Delay_ms(150);
BUZZER = 0; Delay_ms(15); BUZZER = 1;       // SIRENE SOA DUAS VEZES CURTAS
Delay_ms(10000);}}
Exemplo n.º 25
0
void moverManual(){
uart_rd_temp = ' ';
cargarDato();
bandera_automatico = 0;       /* Se limpia la bandera de automatico por si acaso. */
while (uart_rd_temp != 'e') { /* Si se le envía e se sale de modo manual */

waitSignal();
cargarDato();
if (uart_rd_temp == 'u' && bandera_mover) { /* Up: En la interrupción para el auto */
Lcd_Out(2,6,txtArriba);
avanzarVehiculo();
}
 else if (uart_rd_temp == 'd' && bandera_mover) { /* Down:  */
Lcd_Out(2,6,txtAbajo);
moverAtras();
}
 else if (uart_rd_temp == 'l' && bandera_mover) { /* left:  */
Lcd_Out(2,6,txtAbajo);
girarIzquierda();
avanzarVehiculo();
}
 else if (uart_rd_temp == 'r' && bandera_mover) { /* right:  */
Lcd_Out(2,6,txtAbajo);
girarDerecha();
avanzarVehiculo();
}

}
pararVehiculo();
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(2,6,"Se salió de modo manual.");
Delay_ms(100);
uart_rd_temp = ' ';


}
Exemplo n.º 26
0
void task1(void* params)
{
    uint8* var = (uint8*) params;
    const char text_rom[] = "TechRTOS:";
    const char website_rom[] = "-codeforfun.it-";

    static char* website;
    static char* text;

    text = tech_malloc((strlen_rom(text_rom)+1)*sizeof(char));
    strcpy_rom(text, text_rom);

    website = tech_malloc((strlen_rom(website_rom)+1)*sizeof(char));
    strcpy_rom(website, website_rom);

    for (;; yield()) {
        Lcd_OutText(*var, website);
        Lcd_Out(1, 1, text);
    }
}
Exemplo n.º 27
0
/*
* Entry point
*/
void main() {
  // Variables
  char speedBuf[5] = {0,0,0,0,0};
  char totalBuf[] = {0,0,0,0,0,0,0,0,0,0};
  char empty[] = "                ";
  union eeprom_int totalKm;
  int kph = 1;

  // Initialization
  initialize();
  
  // 0x10 = first byte of the actual int value
  // 0x11 = second byte of the actual int value
  totalKm.memory[0] = EEPROM_Read(KM_ADDR);
  totalKm.memory[1] = EEPROM_Read(KM_ADDR+1);

  // 0xFF is 8 bit, an uint is 2 byte = 16 bit, so we need 0xFFFF
  if(totalKm.value == 0xFFFF) {
    totalKm.value = 0;
  }
  
  do {
    // Reads the value of the RA2 Analog knob.
    adcInput = ADC_Read(2);

    
    if(shouldUpdateSpeedometer == 1) {
      shouldUpdateSpeedometer = 0;
      // Update speedometer LCD here
      speed(speedBuf, adcInput, &kph);
      Lcd_Out(1,1,empty);
      Lcd_Out(1,1,"km/t: ");
      Lcd_Out(1,7,speedBuf);
    }
    
    if(shouldUpdateTotal) {
      shouldUpdateTotal = 0;
      // Update LCD and save total here
      total(totalBuf, &totalKm.value, kph);
      
      EEPROM_Write(KM_ADDR, totalKm.memory[0]);
      EEPROM_Write(KM_ADDR+1, totalKm.memory[1]);
      Lcd_Out(2,1,empty);
      Lcd_Out(2,1, "Total: ");
      Lcd_Out(2,8, totalBuf);
    }
    
  }while(1);
}
Exemplo n.º 28
0
void main(){

Lcd_init(); // Initialize LCD
Lcd_Cmd(_LCD_CLEAR);               // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF);
I2C1_Init(100000);
TRISB.F0=0;
TRISB.F1=0;

while(1){

   Read_Compass();
   WordToStr(angle,to_LCD);
   Lcd_Out(1,1,to_LCD);
   straight();
   // delay_ms(500);
  // Lcd_Out(1,1,"Piyumal");
   //delay_ms(1000);
   
}



}
Exemplo n.º 29
0
void main() {


   unsigned short kp;
   int nscale=0;
   char txt[3];

        //initializing scale
   char scale[3][3];
   scale[0][0]='H';scale[0][1]='z';scale[0][2]=' ';
   scale[1][0]='K';scale[1][1]='H';scale[1][2]='z';
   scale[2][0]='M';scale[2][1]='H';scale[2][2]='z';
   TRISA= 0;
   TRISB=0;


  Lcd_Init();                              // Initialize LCD
  Lcd_Cmd(_LCD_CLEAR);                     // Clear display
  Lcd_Cmd(_LCD_CURSOR_OFF);                // Cursor off
  Lcd_Out(1, 1, "Freq:");                  // Write message text on LCD
  Lcd_Out(1, 14, "Hz");
  Lcd_Out(2,1,"Signal Generator");
  Keypad_Init();                           // Initialize Keypad
  while(1)
  {
          int freq_array[3]={0,0,0};
          unsigned long freq;

          kp=0;
          kp=Keypad_Key_Click();

          if(kp!=0 && kp!=1 && kp!=2)         //when any number is pressed
          {
                freq_array[0]=freq_array[1];
                freq_array[1]=freq_array[2];
                freq_array[2]=keyidentifier(kp);
                freq=100*freq_array[2]+10*freq_array[1]+freq_array[0];
                LongToStr(freq,txt);
                Lcd_Out(1,6,txt);
          }

          if(kp==2)         //when scale key pressed
          {
                if(nscale==2){
                        nscale=0;
                }
                else
                {
                        nscale=nscale+1;
                }
                Lcd_Out(1,14,scale[nscale]);
          }

          if(kp==1)         //when start is pressed
          {
                  if(nscale==2)
                  {
                          freq=freq*1000000;
                  }
                  else if(nscale==1)
                  {
                          freq=freq*1000;
                  }
                  else
                  {
                          freq=freq;
                  }

                  set_keyword(freq);
                  send_data_ad9850();
          }

  }

}
Exemplo n.º 30
0
void main()
{
    Time *time;
    ADCON0 = 0;
    ADCON1 = 0x06;              // All ports are digital

    I2C1_Init(100000);          // initialize I2C

    PORTB = 0xFF;
    TRISB = 0;

    // Comment following line for debugging
    OPTION_REG = 0x40;        // Assign prescaler to TMR0 (1/2)
    TMR0  = 12;              // Timer0 initial value
    INTCON = 0xA0;           // Enable TMRO interrupt

    ALARM_COLD_TRIS = 0;

    Lcd_Init();
    Lcd_Cmd(_LCD_CLEAR);
    Lcd_Cmd(_LCD_CURSOR_OFF);
    Lcd_Out(1, 1, "Started!");
    PORTC = 0;

    turnOffFeeder();
    loadFeederData();
    getCustomAlarm(&minTemp, &maxTemp);
    displayEdited(2, 1);

    while(1)
    {
        TRISC = TRISC|BUTTONS_MASK;
        state = PORTC & BUTTONS_MASK;

        if(state != lastState)
        {
          lastState = state;
          if(state & (1<<BUTTON_PREVIOUS))
          {
            if(mode == MODE_EDIT_FEED1_HH || mode == MODE_EDIT_FEED1_MN)
                previousEditFeed1(mode, 0, 2, 1);
            else if(mode == MODE_EDIT_FEED2_HH || mode == MODE_EDIT_FEED2_MN)
                previousEditFeed1(mode, 1, 2, 1);
            else if(mode == MODE_EDIT_MIN || mode == MODE_EDIT_MAX)
                previousEdited(2, 1);
            else
            {
                if(--mode < 0)
                    mode = MODE_COUNT -1;
                displayMode(2, 1);
            }
          }
          else if(state & (1<<BUTTON_NEXT))
          {
            if(mode == MODE_EDIT_FEED1_HH || mode == MODE_EDIT_FEED1_MN)
                nextEditFeed1(mode, 0, 2, 1);
            else if(mode == MODE_EDIT_FEED2_HH || mode == MODE_EDIT_FEED2_MN)
                nextEditFeed1(mode, 1, 2, 1);
            else if(mode == MODE_EDIT_MIN || mode == MODE_EDIT_MAX)
                nextEdited(2, 1);
            else
            {
                if(++mode >= MODE_COUNT)
                    mode = 0;
                displayMode(2, 1);
            }
          }

          if(state & (1<<BUTTON_OK))
            handleOKButton(state);
        }

        if (timerCounter >= 20000)
            handleCounterEvent();
    }
}