Go Down

Topic: I NEED HELP!, i don't know too much about programming if you can please help me. (Read 133 times) previous topic - next topic

Kragnoux

i want to make a mini proyect about a led indicator, like 3 leds and 3 buoy(float), what happens is that the first Led lights up when the water in a small tank if filled with water and it makes every buoy lift up and that lights the led.
ill put images so you can understand me better.(sorry fot bad english).

there are 3 buoys and 3 leds for each buoy. when water touches  a buoy it should lit up a led, and consequently with the other 2 leds.
i want some help and advices please.

this is how i think the coding may be

const int led_a=1;
const int led_b=2;
const int led_c=3;
const int flot_a=4;
const int flot_b=5;
const int flot_c=6;
char led;
boolean valor_flot =false;


void setup() {
Serial.begin(9600);
pinMode(1,INPUT);
pinMode(2,INPUT);
pinMode(3,INPUT);
pinMode(4,OUTPUT);
pinMode(5,OUTPUT);
pinMode(6,OUTPUT);
}

void loop() {
valor_flot = digitalRead(flot);
if valor_flot == true
{else
digitaLWrite(led_a,HIGH);
{else
digitalWrite(led_a,LOW);
}
if valor_flot == true
{else
digitaLWrite(led_b,HIGH);
{else
digitalWrite(led_b,LOW);
}
if valor_flot == true
{else
digitaLWrite(led_c,HIGH);
{else
digitalWrite(led_c,LOW);
}
}

AWOL

Code: [Select]
if valor_flot == true
{else
digitaLWrite(led_a,HIGH);
{else
digitalWrite(led_a,LOW);
}
You need to work through more of the examples in the IDE.
They cover most of the basic syntax you need to work on
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.
I speak for myself, not Arduino.

AWOL

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.
I speak for myself, not Arduino.

tinman13kup

You say there are 3 led's for a bouy, and there are 3 bouys. That makes a total of 9 leds, but you only assigned 3, along with 3 bouys. Is the OP just a bit fuzzy, and there is only 1 led for each of 3 bouys?

As for the thoughts on the code,....there are many things wrong with it. It won't compile at all.

You declare 3 leds, and also 3 bouys. You initilized 3 pins for the leds and 3 pins for the bouys. Then you try to use valor_flot= FALSE for all 3 DIFFERENT bouys, with DIFFERENT pins, performing DIFFERENT functions (even though it is lighting up a led, it's a DIFFERENT led).

Quote
valor_flot = digitalRead(flot);
Which one?? What if 1 float = TRUE and the other 2 = FALSE ?? Perhaps you should read a particular bouy pin?

Quote
if valor_flot == true
{else
digitaLWrite(led_a,HIGH);
{else
digitalWrite(led_a,LOW);
}
Perhaps more like this;
if valorFlotA == TRUE {
digitalWrite (led_a, HIGH)}
else {
digitalWrite(led_a, LOW)}

valorFlotB = digitalRead(flotB);
if valorFlotB == TRUE    ??Starting to see a pattern here?

Start with just 1 bouy. Set the pins and variables and add in the single if/else and make it work. To add the other 2 bous, it is the same thing, with different pins and variables.
Tom
It's not a hobby if you're not having fun doing it. Step back and breathe

wvmarle

Looks more like pseudo code to me than the real thing; does it even compile?
Also please use code tags, and use indentation in your code. Makes it readable.
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

Go Up