an apology for the writing, use the google translator. What I want to do is use 3 sensors Sharp GP2Y0A21YK0F that activate a led, if the first sensor sees, that the led turns on, if the second sensor sees, it turns on the same led, and the same with the third one.
When only one sensor is detected and it detects, the LED is activated, all right up here
#define LD 13
int SENSOR1 = A1; // pin A1
int lectura1;
float conversion1;
void general()
{
digitalWrite (LD, LOW);
}
void setup ()
{
pinMode (LD, OUTPUT);
}
void loop ()
{
lectura1 = analogRead (SENSOR1);
conversion1 = pow (3027.4 / lectura1, 1.2134);
if (conversion1> = 0 && conversion1 <15) {
digitalWrite (LD, HIGH);
}
else
{
general();
}
}
However, when it declares the 3 Sharp when the SENSOR3 detects, the LED lights up completely, but when the SENSOR2 or SENSOR1 detects, the LED turns on very little
#define LD 13
int SENSOR1 = A1; // pin A1
int lectura1;
float conversion1;
int SENSOR2 = A0; // pin A0
int lectura2;
float conversion2;
int SENSOR3 = A2; // pin A2
int lectura3;
float conversion3;
void general ()
{
digitalWrite (LD, LOW);
}
void setup ()
{
pinMode (LD, OUTPUT);
}
void loop ()
{
lectura1 = analogRead (SENSOR1);
conversion1 = pow (3027.4 / lectura1, 1.2134);
lectura2 = analogRead (SENSOR2);
conversion2 = pow (3027.4 / lectura2, 1.2134); // conversions to cm
lectura3 = analogRead (SENSOR3);
conversion3 = pow (3027.4 / lectura3, 1.2134);
if (conversion1> = 0 && conversion1 <15)
{
digitalWrite(LD, HIGH);
}
else
{
general();
}
if (conversion2> = 0 && conversion2 <15)
{
digitalWrite (LD, HIGH);
}
else
{
general();
}
if (conversion3> = 0 && conversion3 <15)
{
digitalWrite (LD, HIGH);
}
else
{
general();
}
}
The sensor that fully activates the LED is the last "if" in the program
I would like you to help me solve this problem, since each sensor activates the LED with different brightness. I await an answer, thank you.
the diagram
https://plus.google.com/photos/photo/114612218997856866388/6611636528582990546?authkey=CLnZnczVyaLsTg