I have placed two sensors and in between the two sensors there are 7 LED been placed when the first sensor gets activated lights in increasing way from 1 to 7 glows and turns off in decreasing way from 7 to 1 now when the second sensors get activated lights from 7 to 1 glows in a decreasing way and gets off in increasing way, now I had tried to make a program where I wanted the first sensor gets high and the lights glow till 3 or 4 or 5 sill glows and at the same time if the second sensor gets high light should start glowing from 7 to 6 to 5 and so on as well
this is the problem query
Your description is very hard to understand. Perhaps you can write it more clearly?
Also please post the program you are talking about.
...R
Down in the lower right corner of your keyboard there is a period key. When you use it, it signifies taking a breath.
That will help people read and understand your query.
ChrisTenone:
Down in the lower right corner of your keyboard there is a period key. When you use it, it signifies taking a breath.That will help people read and understand your query.
+1 !
It may help the OP to understand it as well.
So...
If the left sensor is activated, the lights turn on from left to right and turn off from right to left.
If the right sensor is activated, the lights turn on from right to left and turn off from left to right.
byte LEDPins[7] = {2, 3, 4, 5, 6, 7, 8};
const byte LeftSensorPin = 9;
const byte RightSensorPin = 10;
void setup()
{
SweepRight(LOW); // Turn off all of the output pins
for (int i = 7; i > 0; i--)
{
pinMode(LEDPins[i], OUTPUT);
}
pinMode(LeftSensorPin, INPUT_PULLUP);
pinMode(RightSensorPin, INPUT_PULLUP);
}
void loop()
{
if (digitalRead(LeftSensorPin))
{
SweepRight(HIGH);
SweepLeft(LOW);
}
if (digitalRead(RightSensorPin))
{
SweepLeft(HIGH);
SweepRight(LOW);
}
}
void SweepLeft(boolean value)
{
for (int i = 7; i > 0; i--)
{
digitalWrite(LEDPins[i], value);
delay(100);
}
}
void SweepRight(boolean value)
{
for (int i = 0; i < 7; i++)
{
digitalWrite(LEDPins[i], value);
delay(100);
}
}