kanao
December 7, 2021, 1:55pm
1
int sensor1 = A0;
int sensor2 = A1;
void setup() {
Serial.begin(9600);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
}
void loop() {
sensor1 = analogRead(A0);
sensor2 = analogRead(A1);
Serial.println(A0);
Serial.println(A1);
delay(100);
}
help me with the code always 14,15 when serial println
i use 1k resistor
Serial.println(A0);
Serial.println(A1)
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
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
Koepel
December 7, 2021, 2:13pm
6
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.
Run IoT and embedded projects in your browser: ESP32, Arduino, Pi Pico, and more. No installation required!
system
Closed
June 5, 2022, 2:13pm
7
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.