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

Discussion in 'Programmer's Corner' started by mkbutan, Dec 19, 2012.

  1. mkbutan

    Thread Starter Senior Member

    Sep 30, 2008
    270
    16
    Hi
    I am new to ARDUINO and Programming in 'C'
    I have design the Circuit for the Wire less WATER LEVEL indicator
    with [ Empty 10% , 20% , 25% , 30% , 40% , 50% / HALF , 60% , 70% , 75% , 80% , 90% , 100% / FULL ]
    to be display on the LCD
    but
    I don't know how to write the program for the same.
    any help??????
     
  2. MrChips

    Moderator

    Oct 2, 2009
    12,414
    3,353
    What have you done so far?
     
  3. mkbutan

    Thread Starter Senior Member

    Sep 30, 2008
    270
    16
    I can Switch ON and OFF the one LED on pin #12 of Arduino with an Switch on pin #3 with this code's
    but don't know the idea how to solve my problem


    Code ( (Unknown Language)):
    1.  
    2. /*
    3.   pin 12, when pressing a pushbutton attached to pin 2.
    4.   The circuit:
    5. * LED attached from pin 12 to ground
    6. * pushbutton attached to pin 3 from +5V
    7. * pushbutton attached to pin 4 from +5V
    8. * pushbutton attached to pin 5 from +5V
    9. * pushbutton attached to pin 6 from +5V
    10. */
    11. const int buttonPin = 3;     // the pushbutton pin A
    12. //const int buttonPin = 4;     // the pushbutton pin B
    13. //const int buttonPin = 5;     // the pushbutton pin C
    14. //const int buttonPin = 6;     // the pushbutton pin D
    15. const int ledPin =  12;      // the LED pin
    16.  
    17. int buttonState = 0;
    18.  
    19. void setup()
    20. {
    21.     pinMode(ledPin, OUTPUT);      
    22.     pinMode(buttonPin, INPUT);    
    23. }
    24.  
    25. void loop()
    26. {
    27.     buttonState = digitalRead(buttonPin);
    28.     if (buttonState == HIGH)
    29. {    
    30.     digitalWrite(ledPin, HIGH);  
    31. }
    32.   else
    33. {
    34.     digitalWrite(ledPin, LOW);
    35.   }
    36. }
    37.  
     
    Last edited by a moderator: Dec 19, 2012
  4. mkbutan

    Thread Starter Senior Member

    Sep 30, 2008
    270
    16
    pl any help
     
  5. tshuck

    Well-Known Member

    Oct 18, 2012
    3,531
    675
    I though this sounded familiar!
    http://www.allaboutcircuits.com/vol_4/chpt_14/1.html

    Anyway, describe your hardware.

    You have listed a 433MHz transmitter, it this one of those cheapy ones that you have to provide a modulation scheme to?

    Also, please provide a real schematic, not the scribble you made on the backside of a napkin at lunch...:rolleyes:
     
  6. mcgyvr

    AAC Fanatic!

    Oct 15, 2009
    4,769
    969
    mkbutan,
    How much are they paying YOU to design this circuit?
     
  7. mkbutan

    Thread Starter Senior Member

    Sep 30, 2008
    270
    16

    My dear the Ckt is all ready installed in my house OVER HEAD WATER TANK
    and its working fine based on P89V51RD2
    but i would like to run it on the ARDUINO 328 or MSP430 in place of P89V51RD2

    and no one is Paying me any thing
    Thanks
     
  8. mkbutan

    Thread Starter Senior Member

    Sep 30, 2008
    270
    16
    sir
    please anyone help
     
  9. tshuck

    Well-Known Member

    Oct 18, 2012
    3,531
    675
    Since this is not time-sensitive, take your time, learn how to use the individual components.

    Since you refuse to draw a proper schematic, you'll find many people will not offer much help. They can't read the markings on your napkin. You haven't described your hardware, so we don't know what interface to tell you to use.

    We cannot instinctively know what components are used in this system and before we can help you, you must describe the system to us.
     
  10. mkbutan

    Thread Starter Senior Member

    Sep 30, 2008
    270
    16
    THANKS

    but I don't have the Software to draw the Proper schematic
    but I will draw another one neatly with proper Component marking on it.

    bye the way its not NAPKIN its white paper with LOW RESOLUTION scanning for UPLOADING on the FORUM
     
  11. tshuck

    Well-Known Member

    Oct 18, 2012
    3,531
    675
    A simple search on this site yields:
    http://forum.allaboutcircuits.com/showthread.php?t=18749

    So, go download the tools of this trade if you want the help of this trade.

    I personally use Eagle for most of my schematics...

    All the same, it makes just as much sense...:rolleyes:
     
    mkbutan likes this.
  12. mkbutan

    Thread Starter Senior Member

    Sep 30, 2008
    270
    16
    pl let me know how to make it work?

    what type of FUNCTION should be use here?

    Code ( (Unknown Language)):
    1.  
    2. #include<stdio.h>
    3. #include<conio.h>
    4. void main()
    5. {
    6.      int a,b,c,d;
    7.      printf("Enter the Val of A,B,C,D");
    8.      scanf ("%d,%d,%d,%d",&a,&b,&c,&d);
    9.      printf("Val of a,b,c,d",%d,%d,%d,%d);
    10.      getch();
    11.      }
    12.  
    13. [COLOR="Red"]????????
    14. ????????
    15. ????????[/COLOR]
    16.  
    17. /*
    18. int
    19. {
    20.     if(a=0&&b=0&&c=0&&d=0)
    21.     printf("%a,%b,%c,%d",is "00%" EMPTY);//0000=00
    22.     }
    23.     {
    24.     if(a=0&&b=0&&c=0&&d=1)
    25.     printf("%a,%b,%c,%d",is "10%" );//0001=01
    26.     }
    27.     {
    28.     if(a=0&&b=0&&c=1&&d=0)
    29.     printf("%a,%b,%c,%d",is "20%" );//0010=02
    30.     }
    31.     {
    32.     if(a=0&&b=0&&c=1&&d=1)
    33.     printf("%a,%b,%c,%d",is "25%" );//0011=03
    34.     }
    35.     {
    36.     if(a=0&&b=1&&c=0&&d=0)
    37.     printf("%a,%b,%c,%d",is "30%" );//0100=04
    38.     }
    39.     {
    40.     if(a=0&&b=1&&c=0&&d=1)
    41.     printf("%a,%b,%c,%d",is "40%" );//0101=05
    42.     }
    43.     {
    44.     if(a=0&&b=1&&c=1&&d=0)
    45.     printf("%a,%b,%c,%d",is "50%" );//0110=06
    46.     }
    47.     {
    48.     if(a=0&&b=1&&c=1&&d=1)
    49.     printf("%a,%b,%c,%d",is "60%" );//0111=07
    50.     }
    51.     {
    52.     if(a=1&&b=0&&c=0&&d=0)
    53.     printf("%a,%b,%c,%d",is "70%" );//1000=08
    54.     }
    55.     {
    56.     if(a=1&&b=0&&c=0&&d=1)
    57.     printf("%a,%b,%c,%d",is "75%" );//1001=09
    58.     }
    59.     {
    60.     if(a=1&&b=0&&c=1&&d=0)
    61.     printf("%a,%b,%c,%d",is "80%" );//1010=10
    62.     }
    63.     {
    64.     if(a=1&&b=0&&c=1&&d=1)
    65.     printf("%a,%b,%c,%d",is "90%" );//1011=11
    66.     }
    67.     {
    68.     if(a=1&&b=1&&c=0&&d=0)
    69.     printf("%a,%b,%c,%d",is "100%" FULL);//1100=12
    70.     }
    71.     {
    72.     if(a=1&&b=1&&c=0&&d=1)
    73.     printf("%a,%b,%c,%d",is "100" Alarm);//1101=13
    74.     }
    75.     {
    76.     if(a=1&&b=1&&c=1&&d=0)
    77.     printf("%a,%b,%c,%d",is "xxx%" );//1110=14
    78.     }
    79.     {
    80.     if(a=1&&b=1&&c=1&&d=1)
    81.     printf("%a,%b,%c,%d",is "xxx%" );//1111=15
    82.     }
    83.  */
     
  13. tshuck

    Well-Known Member

    Oct 18, 2012
    3,531
    675
    We don't know what you are trying to do! You refuse to make a schematic and refuse to describe your hardware. How can you expect anyone to help you when you won't even do the minimum for others to understand your system!?
     
    mkbutan likes this.
  14. mkbutan

    Thread Starter Senior Member

    Sep 30, 2008
    270
    16
    I have put one FUNCTION (Display) in the code's
    but still not functional

    is there any way by which we can convert BCD to DEC code's and can be printed out as output

    I know its wrong please help me to make it right
    thanks
    [ the CODE's is for 'C' not for 'ARDUINO' ]


    Code ( (Unknown Language)):
    1.  
    2. #include<stdio.h>
    3. #include<conio.h>
    4. void display(int z)
    5. int main(void)
    6. {
    7.      int a,b,c,d;
    8.      int x0,x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12,x13,x14,x15;
    9.      x0=00;
    10.      x1=10;
    11.      x2=20;
    12.      x3=25;
    13.      x4=30;
    14.      x5=40;
    15.      x6=50;
    16.      x7=60;
    17.      x8=70;
    18.      x9=75;
    19.      x10=80;
    20.      x11=90;
    21.      x12=100;
    22.      x13=0;
    23.      x14=0;
    24.      x15=0;
    25.      printf("Enter the Val of A,B,C,D\n");
    26.      scanf("%d,%d,%d,%d",&a,&b,&c,&d);
    27.      printf("Val of a,b,c,d,%d,%d,%d,%d",a,b,c,d);
    28.      display(int z)
    29.      getch();
    30.      }
    31.  
    32.  
    33. {
    34.  
    35.     void display(int z)
    36.  
    37. {
    38.     if(a==0&&b==0&&c==0&&d==0)
    39.     printf("%a,%b,%c,%d is 00% EMPTY",x0);//0000=00
    40.     }
    41. {
    42.     if(a==0&&b==0&&c==0&&d==1)
    43.     printf("%a,%b,%c,%d is 10%",x1);//0001=01
    44.     }
    45. {
    46.     if(a==0&&b==0&&c==1&&d==0)
    47.     printf("%a,%b,%c,%d is 20%",x2);//0010=02
    48.     }
    49. {
    50.     if(a==0&&b==0&&c==1&&d==1)
    51.     printf("%a,%b,%c,%d is 25%",x3);//0011=03
    52.     }
    53. {
    54.     if(a==0&&b==1&&c==0&&d==0)
    55.     printf("%a,%b,%c,%d is 30%",x4);//0100=04
    56.     }
    57. {
    58.     if(a==0&&b==1&&c==0&&d==1)
    59.     printf("%a,%b,%c,%d is 40%".x5);//0101=05
    60.     }
    61. {
    62.     if(a==0&&b==1&&c==1&&d==0)
    63.     printf("%a,%b,%c,%d is 50%",x6 HALF);//0110=06
    64.     }
    65. {
    66.     if(a==0&&b==1&&c==1&&d==1)
    67.     printf("%a,%b,%c,%d is 60%",x7);//0111=07
    68.     }
    69. {
    70.     if(a==1&&b==0&&c==0&&d==0)
    71.     printf("%a,%b,%c,%d is 70%",x8);//1000=08
    72.     }
    73. {
    74.     if(a==1&&b==0&&c==0&&d==1)
    75.     printf("%a,%b,%c,%d is 75%",x9);//1001=09
    76.     }
    77. {
    78.     if(a==1&&b==0&&c==1&&d==0)
    79.     printf("%a,%b,%c,%d is 80%",x10);//1010=10
    80.     }
    81. {
    82.     if(a==1&&b==0&&c==1&&d==1)
    83.     printf("%a,%b,%c,%d is 90%",x11);//1011=11
    84.     }
    85. {
    86.     if(a==1&&b==1&&c==0&&d==0)
    87.     printf("%a,%b,%c,%d is 100% FULL",x12);//1100=12
    88.     }
    89. {
    90.     if(a==1&&b==1&&c==0&&d==1)
    91.     printf("%a,%b,%c,%d is 100% ALARM",x13);//1101=13
    92.     }
    93. {
    94.     if(a==1&&b==1&&c==1&&d==0)
    95.     printf("%a,%b,%c,%d is xXx",x14 );//1110=14
    96.     }
    97. {
    98.     else(a==1&&b==1&&c==1&&d==1)
    99.     printf("%a,%b,%c,%d is XxX",x15);//1111=15
    100.     }
    101.  
    102. }
    103.  
    104.  
     
  15. mkbutan

    Thread Starter Senior Member

    Sep 30, 2008
    270
    16
    thanks its not for the ckt its about Program CODE
     
  16. tshuck

    Well-Known Member

    Oct 18, 2012
    3,531
    675
    So you are asking how to do this while this code is running on a computer.

    Look at how printf works...

    You need to explain what you are trying to do, regardless of whether it is software or hardware.
     
    mkbutan likes this.
  17. mkbutan

    Thread Starter Senior Member

    Sep 30, 2008
    270
    16
    ##1
    I think the (Tx section) have 00-15(0000-1111) binary input as a switch in the water tank (here we use 00-13(0000-1101) for the sensing switches in the tank) and 14(1110)turn on the audio (UM66) and 15(1111) to turn off the tank input.
    The 16-04 Multiplexer convert the 16 I/P to 04 Hex (0000-1111) which will be Tx via HT12E

    ##2
    and the (RX Section) have 04 O/P via HT12D and fed to 04-16 De-Multiplexer and will light the LED indicator as 00-13 (0000-1101) with
    [ 00% , 10% , 20% , 25% , 30% , 40% , 50% , 60% , 70% , 75% , 80% , 90% , 100% ] 14(1110) turn on the audio (UM66) and 15(1111) to turn off the tank input.


    ##3
    and the Arduino 328 will have pin no. 3,4,5 & 6 from HT12D as an Binary I/P as (000-1111) which to be displayed on the LCD of 2x16 as
    [ 00% / Empty 10% , 20% , 25% , 30% , 40% , 50% / HALF , 60% , 70% , 75% , 80% , 90% , 100% / FULL ] from the pin no. 7,8,9,10,11,12 &13 of the ARDUINO 328...

    The tx/rx is working I would like to add the ARDUINO or the MSP430 with it.

    I just wanted to know how to write code for the ARDUINO 328
    which have 4 pins input A,B,C,D as (0000 to 1111) on Arduino pin no 3,4,5 & 6
    and the output to be displayed on the LCD as desired. the Arduino 328 will have
    pin no. 3,4,5 & 6 from HT12D as an Binary I/P as (000-1111)
    which to be displayed on the LCD of 2x16 as
    [ Empty 10% , 20% , 25% , 30% , 40% , 50% / HALF , 60% , 70% , 75% , 80% , 90% , 100% / FULL ]
    from the pin no. 7,8,9,10,11,12 &13 of the ARDUINO 328

    any IDEA pl ????
     
  18. mkbutan

    Thread Starter Senior Member

    Sep 30, 2008
    270
    16
    thanks for the LINK its very helpfull
     
  19. tshuck

    Well-Known Member

    Oct 18, 2012
    3,531
    675
    I/P = input?
    o/P = output?
    A multiplexer has only one output. You must mean an encoder. It is not converting to 04 HEX. It is encoding the value to 4 bits, or one hexadecimal number.

    this is a decoder...


    Normally, I'd say read the port and shift as necessary until you get the bits like this: [0 0 0 0 (pin6) (pin5) (pin4) (pin3)] as a 8-bit variable, but, since I don't know if you have access to the ports like this in Arduino, I'll give you a general solution:
    read in pins 3,4,5,and 6 and store them into a variable with each bit having different weights.
    As in, and this is probably the wrong code
    Code ( (Unknown Language)):
    1.  
    2. unsigned char data = digitalRead(PIN6) << 3 | digitalRead(PIN5) << 2 | digitalRead(PIN4) << 1 | digitalRead(PIN3);
    3.  
    After that, it should be pretty easy to display the data on the LCD, switch on the data and push "XX%" to the LCD, as there are libraries for everything on Arduino...
     
    mkbutan likes this.
  20. mkbutan

    Thread Starter Senior Member

    Sep 30, 2008
    270
    16
    now also its not correct
    please help
    error on Line #31
    \4-16v1.c|31|error: syntax error before '{' token|

    Code ( (Unknown Language)):
    1.  
    2. #include<stdio.h>
    3. #include<conio.h>
    4. void display(int z);
    5. int main(void)
    6. {
    7.      int a,b,c,d;
    8.      int x[16] = {0,10,20,25,30,40,50,60,70,75,80,90,100,100,100,100};
    9.  
    10.      printf("Enter the Val of A,B,C,D\n");
    11.      scanf("%d,%d,%d,%d",&a,&b,&c,&d);
    12.      printf("Val of a,b,c,d,%d,%d,%d,%d",a,b,c,d);
    13.  
    14. void display(int z);
    15. {
    16.   int index = a*8 + b*4 + c*2 + d;
    17.    printf("%d, %d, %d, %d is %d %%", a, b, c, d, x[index]);
    18.    getch();
    19.      }
    20.      }
    21.  
    22.  
    23.  
    24.  
    25.     void display(int z)
    26.     {
    27.         int a,b,c,d;
    28.      int x[16] = {0,10,20,25,30,40,50,60,70,75,80,90,100,100,100,100};
    29.  
    30.     }
    31.  
    32.     {
    33.  
    34.  
    35. {
    36.     if(a==0 && b==0 && c==0 && d==0)
    37.     printf("%d,%d,%d,%d is %d%% EMPTY",a,b,c,d,x[0]);//0000=00
    38.     }
    39. {
    40.     if(a==0 && b==0 && c==0 && d==1)
    41.     printf("%d, %d, %d, %d is %d %%", a,b,c,d, x[1]);//0001=01
    42.     }
    43. {
    44.     if(a==0 && b==0 && c==1 && d==0)
    45.     printf("%d, %d, %d, %d is %d %%", a,b,c,d, x[2]);//0010=02
    46.     }
    47. {
    48.     if(a==0 && b==0 && c==1 && d==1)
    49.     printf("%d, %d, %d, %d is %d %%", a,b,c,d, x[3]);//0011=03
    50.     }
    51. {
    52.     if(a==0 && b==1 && c==0 && d==0)
    53.     printf("%d, %d, %d, %d is %d %%", a,b,c,d, x[4]);//0100=04
    54.     }
    55. {
    56.     if(a==0 && b==1 && c==0 && d==1)
    57.     printf("%d, %d, %d, %d is %d %%", a,b,c,d, x[5]);//0101=05
    58.     }
    59. {
    60.     if(a==0 && b==1 && c==1 && d==0)
    61.     printf("%d, %d, %d, %d is %d %%", a,b,c,d, x[6]);//0110=06
    62.     }
    63. {
    64.     if(a==0 & &b==1 && c==1 && d==1)
    65.     printf("%d, %d, %d, %d is %d %%", a,b,c,d, x[7]);//0111=07
    66.     }
    67. {
    68.     if(a==1 && b==0 && c==0 && d==0)
    69.     printf("%d, %d, %d, %d is %d %%", a,b,c,d, x[8]);//1000=08
    70.     }
    71. {
    72.     if(a==1 && b==0 && c==0 && d==1)
    73.     printf("%d, %d, %d, %d is %d %%", a,b,c,d, x[9]);//1001=09
    74.     }
    75. {
    76.     if(a==1 && b==0 && c==1 && d==0)
    77.     printf("%d, %d, %d, %d is %d %%", a,b,c,d, x[10]);//1010=10
    78.     }
    79. {
    80.     if(a==1 && b==0 && c==1 && d==1)
    81.     printf("%d, %d, %d, %d is %d %%", a,b,c,d, x[10]);//1011=11
    82.     }
    83. {
    84.     if(a==1 && b==1 && c==0 && d==0)
    85.     printf("%d, %d, %d, %d is %d %%", a,b,c,d, x[12]);//1100=12
    86.     }
    87. {
    88.     if(a==1 && b==1 && c==0 && d==1)
    89.     printf("%d, %d, %d, %d is %d %%", a,b,c,d, x[13]);//1101=13
    90.     }
    91. {
    92.     if(a==1 && b==1 && c==1 && d==0)
    93.     printf("%d, %d, %d, %d is %d %%", a,b,c,d, x[14]);//1110=14
    94.     }
    95. {
    96.     else(a==1 && b==1 & &c==1 && d==1)
    97.     printf("%d, %d, %d, %d is %d %%", a,b,c,d, x[15]);//1111=15
    98.     }
    99.  
    100. }
    101.  
    102.  
     
Loading...