// Define the pins for the potentiometers and LDRs
const int potentiometerPins[] = {A4, A5, A6, A7};
const int ldrPins[] = {A0, A1, A2, A3};
const int numSensors = 4;
unsigned long previousMillis = 0;
const long interval = 500; // 1 second interval
void setup() {
// Start serial communication
Serial.begin(9600);
}
void loop() {
unsigned long currentMillis = millis();
// Check if it's time to read and display values
if (currentMillis - previousMillis >= interval) {
// Save the last time you read the values
previousMillis = currentMillis;
for (int i = 0; i < numSensors; i++) {
// Map the potentiometer value to a range of 1 to 200
int x = map(analogRead(potentiometerPins[i]), 0, 1023, 100, 20000);
float xfloat = x/100.00;
// Read the value of the LDR and map it
int y = map(analogRead(ldrPins[i]), 8, 1015, 10000, 1);
// Calculate the adjusted LDR value as a percentage
float FinalVal = ((float)xfloat * (float)y) / 100.00;
// Print the values to the serial monitor
Serial.print("Sensor: ");
Serial.print(i + 1);
Serial.print("\t Sensitivity: ");
Serial.print(xfloat);
Serial.print("\t ldr: ");
Serial.print(y);
Serial.print("\t FinalVal: ");
Serial.println(FinalVal);
}
}
}
nano:12
nano:11
nano:10
nano:9
nano:8
nano:7
nano:6
nano:5
nano:4
nano:3
nano:2
nano:GND.2
nano:RESET.2
nano:0
nano:1
nano:13
nano:3.3V
nano:AREF
nano:A0
nano:A1
nano:A2
nano:A3
nano:A4
nano:A5
nano:A6
nano:A7
nano:5V
nano:RESET
nano:GND.1
nano:VIN
nano:12.2
nano:5V.2
nano:13.2
nano:11.2
nano:RESET.3
nano:GND.3
pot2:GND
pot2:SIG
pot2:VCC
pot3:GND
pot3:SIG
pot3:VCC
pot4:GND
pot4:SIG
pot4:VCC
pot1:GND
pot1:SIG
pot1:VCC
ldr1:VCC
ldr1:GND
ldr1:DO
ldr1:AO
ldr2:VCC
ldr2:GND
ldr2:DO
ldr2:AO
ldr3:VCC
ldr3:GND
ldr3:DO
ldr3:AO
ldr4:VCC
ldr4:GND
ldr4:DO
ldr4:AO