# value of the light intensity, measured on an analog input pin of the Arduino

Hello good people,

I need a program for the Arduino where the value of the light intensity, measured on an analog input pin of the Arduino, is used as the upper limit for the PWM modulation of your two LEDs. The LEDs are modulated in opposite directions.

The modulation thus affects between minmod and maxmod, where the value of maxmod is determined by a measured value from one of the analog ports of the Arduino. The more light there is, the larger maxmod becomes and the slower the modulation. The less light there is, the smaller maxmod becomes and the faster the modulation.

At the beginning of the program, you even turn on both LEDs to see if they work.

In the course material you will find the instructions for reading an analog port on the Arduino.

Make sure maxmod never exceeds 255.

Can someone help me please write this code?

In the course material you will find the instructions for reading an analog port on the Arduino.

Can you read the sensor and print the value returned in the Serial monitor

When is our assignment due to be handed in ?

File => Examples => 03. Analog => Analog Input File => Examples => 03. Analog => Fading

UKHeliBob: When is our assignment due to be handed in ?

How much are we to be paid* for completing "our" assignment? :confused:

*Note to OP/mods: I'm joking.

Thanks for the fast reply’s. Well i have another 1 week but i have been struggling for a long time to get this arduino course done (part of my education, which i will never use again probably) so i’m asking the internet for help… all i have now is this code:

int maxmod = 200;
int minmod = 10;
int modulatie = 0;
int tegenmodulatie = 0;

void setup() {

pinMode(10,OUTPUT);
pinMode(11,OUTPUT);

digitalWrite(10,HIGH);
digitalWrite(11,HIGH);
delay(2000);
digitalWrite(10,LOW);
digitalWrite(11,LOW);
}

void loop() {

maxmod = min(maxmod, 255);
minmod = max(0, minmod);

for ( int modulatie = minmod ; modulatie <= maxmod; modulatie += 1) {
tegenmodulatie = maxmod - modulatie + minmod;
analogWrite(10, modulatie);
analogWrite(11, tegenmodulatie);
delay(10);
}
for (int modulatie = maxmod ; modulatie >= minmod ; modulatie -= 1) {
tegenmodulatie = maxmod - modulatie + minmod;
analogWrite(10, modulatie);
analogWrite(11, tegenmodulatie);
delay(10);
}
}