Help with two LDR sensor program

int sensor1 = A0;
int sensor2 = A1;

void setup() {
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
void loop() {
  sensor1 = analogRead(A0);
  sensor2 = analogRead(A1);

help me with the code always 14,15 when serial println
i use 1k resistor


You are printing the values of the pins rather than the values that you just read from them. Print sensor1 and sensor2 instead

1 Like

Thank you @UKHeliBob

sensor1 = analogRead(A0);
means read value from IO--pin 14 and store this value into variable sensor1

sensor2 = analogRead(A1);
means read value from IO-pin 15 and store this value into variable sensor2

so you have to print the value of vaiable sensor1 and sensor2

best regards Stefan

1 Like

Thank you sir @StefanL38

When a variable is a pin, you could add the word "pin".

int sensorPin1 = A0;
int sensorPin2 = A1;

The Wokwi simulation does not have a LDR, because it can not do analog simulation. But it does have a ldr-module.
I made your project with Wokwi. Start the simulation and click on a ldr-module to change the light. The Serial Monitor is set in "plotter" mode.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.