Error when Run code

mikroC, mikroBasic and mikroPascal PRO for Microchip’s (formerly Atmel) 8-bit AVR MCUs
Post Reply
Author
Message
moafaneh
Posts: 1
Joined: 23 Jan 2021 17:18

Error when Run code

#1 Post by moafaneh » 23 Jan 2021 17:33

Hello Everyone, the following code display an error when i press error i can know what is the problem

Code: Select all

//Interface of DHT11 with PIC16F84A MikroC code
//Please read the datasheet of DHT11 sensor to understand the code
//Written by: BENCHEROUDA Okba
//electronnote@gmail.com
//Use at your own risk

// LCD module connections
 sbit LCD_RS at RB5_bit;
 sbit LCD_EN at RB4_bit;
 sbit LCD_D4 at RB3_bit;
 sbit LCD_D5 at RB2_bit;
 sbit LCD_D6 at RB1_bit;
 sbit LCD_D7 at RB0_bit;
 sbit LCD_RS_Direction at TRISB5_bit;
 sbit LCD_EN_Direction at TRISB4_bit;
 sbit LCD_D4_Direction at TRISB3_bit;
 sbit LCD_D5_Direction at TRISB2_bit;
 sbit LCD_D6_Direction at TRISB1_bit;
 sbit LCD_D7_Direction at TRISB0_bit;
 // End LCD module connections
 unsigned char *text,mytext[4];
 unsigned  a, b, i, t, rh;

 void StartSignal(){
 TRISB.F6 = 0;    //Configure RB6 as output
 PORTB.F6 = 0;    //RB6 sends 0 to the sensor
 delay_ms(18);
 PORTB.F6 = 1;    //RB6 sends 1 to the sensor
 delay_us(30);
 TRISB.F6 = 1;    //Configure RB6 as input
  }
 void CheckResponse(){
 a = 0;
 delay_us(40);
 if (PORTB.F6 == 0){
 delay_us(80);
 if (PORTB.F6 == 1)   a = 1;   delay_us(40);}
 }
 void ReadData(){
 for(b=0; b<8; b++){
 while(!PORTB.F6);                   //Wait until PORTB.F6 goes HIGH
 delay_us(30);
 if(PORTB.F6 == 0)  i&=~(1<<(7-b));   //Clear bit (7-b)
 else{i|= (1 <<( 7 - b));             //Set bit (7-b)
 while(PORTB.F6);}                    //Wait until PORTB.F6 goes LOW
 }
 }
 void error(){
 text="ERROR";
  Lcd_Out(1,6,text);
  }
 void main() {
 TRISB = 0;        //Configure PORTB as output
 PORTB = 0;        //Initial value of PORTB
 Lcd_Init();
 while(1){
 Lcd_Cmd(_LCD_CURSOR_OFF);        // cursor off
 Lcd_Cmd(_LCD_CLEAR);             // clear LCD
  StartSignal();
  CheckResponse();
  if(a == 1){
  ReadData();
  rh = i;
  ReadData();
  ReadData();
  t = i;
  ReadData();
  ReadData();
  if(i = rh + t){
  text = "Temp:  .0C";
  Lcd_Out(1, 4, text);
  text = "Humi:  .0%";
  Lcd_Out(2, 4, text);
  ByteToStr(t,mytext);
  Lcd_Out(1, 9, Ltrim(mytext));
  ByteToStr(rh,mytext);
  Lcd_Out(2, 9, Ltrim(mytext));}
  else error();
  }
  else error();
  delay_ms(2000);
  }
  }
 
This is the errors
Image

Please help me with this
thanks

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: Error when Run code

#2 Post by filip » 26 Jan 2021 13:42

Hi,

The identifier a is already declared in the definition file of the MCU, please change the name to aa (for example) and the code will compile.

Regards,
Filip.

Post Reply

Return to “AVR PRO Compilers”