light a LED

Hi, I'm new to the forum community and also Arduino. I need to solve a programming problem in Arduino and I have no idea how to start :confused: 1. In the following scenario develops a program to perform the following actions.

-As the light is in a range between 0 and 100, should completely turn on the LED. -As the light is in a range between 101 and 400, should turn the led to 50%. -In the range of 401-1023 should be off. -A second LED to 50% should ignite if it detects movement in the range of 2.1 meters to 4 meters (motion sensor). -100% if the rago of 0 meters to 2 meters :)

I have to wonder why someone who is brand new to Arduino, with no idea how to start, would arrive at such a specific description of a project. Is this an academic assignment?

Am I the only one who's missing the question mark? And code, it's the programming section after all.

And how can a light be in a range? ::)

tmd3: Is this an academic assignment?

The "1." that got copied over with it sort of gives it away doesn't it.

septillion: Am I the only one who's missing the question mark? And code, it's the programming section after all.

And how can a light be in a range? ::)

I think it means ambient light.

I think he means a variable, possibly representing the reading of an ambient light sensor :)

septillion: I think he means a variable, possibly representing the reading of an ambient light sensor :)

Considering the range (up to 1023) he's probably reading from an analog pin.

@edgar_ivan14, you need to make a start on the coding, then ask for help if you strike problems.

Use ‘analogRead()’ to read the analogue output of the light sensor. Then use ‘if’ statements to determine the light strength and light the LED appropriately, using ‘analogWrite()’ on a PWM output pin to set the LED brightness.

-A second LED to 50% should ignite if it detects movement in the range of 2.1 meters to 4 meters (motion sensor).
-100% if the rago of 0 meters to 2 meters

This part is a problem - a PIR motion sensor does not measure the distance to the target. For that you’ll probably need an ultrasonic ‘ping’ sensor.