Help for the Wire less Water Level Indicator for Programming the ARDUINO 328

tshuck

Joined Oct 18, 2012
3,534
now also its not correct
please help
error on Line #31
\4-16v1.c|31|error: syntax error before '{' token|

Rich (BB code):
#include<stdio.h>
#include<conio.h>
void display(int z);
int main(void)
{
     int a,b,c,d;
     int x[16] = {0,10,20,25,30,40,50,60,70,75,80,90,100,100,100,100};

     printf("Enter the Val of A,B,C,D\n");
     scanf("%d,%d,%d,%d",&a,&b,&c,&d);
     printf("Val of a,b,c,d,%d,%d,%d,%d",a,b,c,d);

void display(int z);
{
  int index = a*8 + b*4 + c*2 + d;
   printf("%d, %d, %d, %d is %d %%", a, b, c, d, x[index]);
   getch();
     }
     }




    void display(int z)
    {
        int a,b,c,d;
     int x[16] = {0,10,20,25,30,40,50,60,70,75,80,90,100,100,100,100};

    }

    {


{
    if(a==0 && b==0 && c==0 && d==0)
    printf("%d,%d,%d,%d is %d%% EMPTY",a,b,c,d,x[0]);//0000=00
    }
{
    if(a==0 && b==0 && c==0 && d==1)
    printf("%d, %d, %d, %d is %d %%", a,b,c,d, x[1]);//0001=01
    }
{
    if(a==0 && b==0 && c==1 && d==0)
    printf("%d, %d, %d, %d is %d %%", a,b,c,d, x[2]);//0010=02
    }
{
    if(a==0 && b==0 && c==1 && d==1)
    printf("%d, %d, %d, %d is %d %%", a,b,c,d, x[3]);//0011=03
    }
{
    if(a==0 && b==1 && c==0 && d==0)
    printf("%d, %d, %d, %d is %d %%", a,b,c,d, x[4]);//0100=04
    }
{
    if(a==0 && b==1 && c==0 && d==1)
    printf("%d, %d, %d, %d is %d %%", a,b,c,d, x[5]);//0101=05
    }
{
    if(a==0 && b==1 && c==1 && d==0)
    printf("%d, %d, %d, %d is %d %%", a,b,c,d, x[6]);//0110=06
    }
{
    if(a==0 & &b==1 && c==1 && d==1)
    printf("%d, %d, %d, %d is %d %%", a,b,c,d, x[7]);//0111=07
    }
{
    if(a==1 && b==0 && c==0 && d==0)
    printf("%d, %d, %d, %d is %d %%", a,b,c,d, x[8]);//1000=08
    }
{
    if(a==1 && b==0 && c==0 && d==1)
    printf("%d, %d, %d, %d is %d %%", a,b,c,d, x[9]);//1001=09
    }
{
    if(a==1 && b==0 && c==1 && d==0)
    printf("%d, %d, %d, %d is %d %%", a,b,c,d, x[10]);//1010=10
    }
{
    if(a==1 && b==0 && c==1 && d==1)
    printf("%d, %d, %d, %d is %d %%", a,b,c,d, x[10]);//1011=11
    }
{
    if(a==1 && b==1 && c==0 && d==0)
    printf("%d, %d, %d, %d is %d %%", a,b,c,d, x[12]);//1100=12
    }
{
    if(a==1 && b==1 && c==0 && d==1)
    printf("%d, %d, %d, %d is %d %%", a,b,c,d, x[13]);//1101=13
    }
{
    if(a==1 && b==1 && c==1 && d==0)
    printf("%d, %d, %d, %d is %d %%", a,b,c,d, x[14]);//1110=14
    }
{
    else(a==1 && b==1 & &c==1 && d==1)
    printf("%d, %d, %d, %d is %d %%", a,b,c,d, x[15]);//1111=15
    }

}
Please don't simply post something you haven't even looked at. Look at where the error is and see if anything jumps out at you. If not, go learn how to program. This is a simple error.
 

Thread Starter

mkbutan

Joined Sep 30, 2008
299
hi
I have tried to make the sketch of my program
pl help me to make it functional

Rich (BB code):
const int aPin=6;
const int bPin=7;
const int cPin=8;
const int dPin=9;
//int pinMode[INPUT]{a,b,c,d};
int a,b,c,d;
int x[16] = {0,10,20,25,30,40,50,60,70,75,80,90,100,100,100,100};
int display(int z);
#include <LiquidCrystal.h>
LiquidCrystal lcd(12,11,5,4,3,2);

void setup()
{
  lcd.begin(16,2);
  lcd.print("WATER LEVEL");
  pinMode(aPin,INPUT);
  pinMode(bPin,INPUT);
  pinMode(cPin,INPUT);
  pinMode(dPin,INPUT);
     
  
  }
  
void loop()
{
  lcd.noDisplay();  //Display
  delay(150);
  lcd.display();
  delay(150);
  int a,b,c,d;
     int x[16] = {0,10,20,25,30,40,50,60,70,75,80,90,100,100,100,100};
      // Condition's
       if(a==0 && b==0 && c==0 && d==0)  //Cond : 01
        lcd.print("%d,%d,%d,%d is %d%% EMPTY",a,b,c,d,x[0]);//0000=00
        
  else if(a==0 && b==0 && c==0 && d==1)  //Cond : 02
	lcd.print("%d, %d, %d, %d is %d %%", a,b,c,d, x[1]);//0001=01

  else if(a==0 && b==0 && c==1 && d==0)  //Cond : 03
	lcd.print("%d, %d, %d, %d is %d %%", a,b,c,d, x[2]);//0010=02

  else if(a==0 && b==0 && c==1 && d==1)  //Cond : 04
	lcd.print("%d, %d, %d, %d is %d %%", a,b,c,d, x[3]);//0011=03

  else if(a==0 && b==1 && c==0 && d==0)  //Cond : 05
	lcd.print("%d, %d, %d, %d is %d %%", a,b,c,d, x[4]);//0100=04

  else if(a==0 && b==1 && c==0 && d==1)  //Cond : 06
	lcd.print("%d, %d, %d, %d is %d %%", a,b,c,d, x[5]);//0101=05

  else if(a==0 && b==1 && c==1 && d==0)  //Cond : 07
	lcd.print("%d, %d, %d, %d is %d %%", a,b,c,d, x[6]);//0110=06

  else if(a==0 && b==1 && c==1 && d==1)  //Cond : 08
	lcd.print("%d, %d, %d, %d is %d %%", a,b,c,d, x[7]);//0111=07

  else if(a==1 && b==0 && c==0 && d==0)  //Cond : 09
	lcd.print("%d, %d, %d, %d is %d %%", a,b,c,d, x[8]);//1000=08

  else if(a==1 && b==0 && c==0 && d==1)  //Cond : 10
	lcd.print("%d, %d, %d, %d is %d %%", a,b,c,d, x[9]);//1001=09

  else if(a==1 && b==0 && c==1 && d==0)  //Cond : 11
	lcd.print("%d, %d, %d, %d is %d %%", a,b,c,d, x[10]);//1010=10

  else if(a==1 && b==0 && c==1 && d==1)  //Cond : 12
	lcd.print("%d, %d, %d, %d is %d %%", a,b,c,d, x[10]);//1011=11

  else if(a==1 && b==1 && c==0 && d==0)  //Cond : 13
	lcd.print("%d, %d, %d, %d is %d %%", a,b,c,d, x[12]);//1100=12

  else if(a==1 && b==1 && c==0 && d==1)  //Cond : 14
	lcd.print("%d, %d, %d, %d is %d %%", a,b,c,d, x[13]);//1101=13

  else if(a==1 && b==1 && c==1 && d==0)  //Cond : 15
	lcd.print("%d, %d, %d, %d is %d %%", a,b,c,d, x[14]);//1110=14

  else if(a==1 && b==1 && c==1 && d==1)  //Cond : 16
	lcd.print("%d, %d, %d, %d is %d %%", a,b,c,d, x[15]);//1111=15
}
  // Function
  int display(int z);
  {
  int index = (!!a)*8 + (!!b)*4 + ((!!c)*2) + (!!d);
  int index = a*8 + b*4 + c*2 + d;
}
 

Attachments

Last edited:

Thread Starter

mkbutan

Joined Sep 30, 2008
299
while compiling it gives the following ERROR
I cant understand these ERRORS

_4_16_v1_2.ino: In function 'void loop()':
_4_16_v1_2:34: error: no matching function for call to 'LiquidCrystal:: print(const char [26], int&, int&, int&, int&, int&)'
Print.h:55: note: candidates are: size_t Print: print(const __FlashStringHelper*)
Print.h:56: note: size_t Print: print(const String&)
Print.h:57: note: size_t Print: print(const char*)
C:\Users\M.K.Butan\Desktop\DevlepMent\arduino-1.0.3\hardware\arduino\cores\arduino/Print.h:58: note: size_t Print::print(char)
Print.h:59: note: size_t Print: print(unsigned char, int)
Print.h:60: note: size_t Print: print(int, int)
Print.h:61: note: size_t Print: print(unsigned int, int)
Print.h:62: note: size_t Print: print(long int, int)
Print.h:63: note: size_t Print: print(long unsigned int, int)
Print.h:64: note: size_t Print: print(double, int)
Print.h:65: note: size_t Print: print(const Printable&)
_4_16_v1_2:37: error: no matching function for call to 'LiquidCrystal::print(const char [24], int&, int&, int&, int&, int&)'
Print.h:55: note: candidates are: size_t Print : print(const __FlashStringHelper*)

...........................................

C:\Users\M.K.Butan\Desktop\DevlepMent\arduino-1.0.3\hardware\arduino\cores\arduino/Print.h:65: note: size_t Print:: print(const Printable&)
_4_16_v1_2.ino: At global scope:
_4_16_v1_2:83: error: expected unqualified-id before '{' token
 

Thread Starter

mkbutan

Joined Sep 30, 2008
299
hi
dear all thanks for your support these code's are working in ARDUINO for my project
thanks once again

Rich (BB code):
#include <LiquidCrystal.h>

LiquidCrystal lcd(12,11,5,4,3,2);

const int aPin=6;
const int bPin=7;
const int cPin=8;
const int dPin=9;

int a,b,c,d;
int x[16] = {
  0,10,20,25,30,40,50,60,70,75,80,90,100,100,100,100};

void setup()
{
  lcd.begin(16,2);
  lcd.print("WATER LEVEL");
  pinMode(aPin, INPUT);
  pinMode(bPin, INPUT);
  pinMode(cPin, INPUT);
  pinMode(dPin, INPUT);
}

void loop()
{
  // MAKE MEASUREMENTS
  a = digitalRead(aPin);
  b = digitalRead(bPin);
  c = digitalRead(cPin);
  d = digitalRead(dPin);


  // DO THE MATH
  int index =  a*8 + b*4 + c*2 + d;


  // DISPLAY THE RESULTS
  if (index == 0) 
  {
    lcd.setCursor(0,1);
    lcd.print("EMPTY"); 
  }
  else 
  {
    lcd.setCursor(0,1);
    lcd.print(x[index]);
    lcd.print("%   ");  // extra spaces removes crap on the display
  }
  delay(1000); // read blink without delay example to get rid of this line
}
 
Top