#include <LiquidCrystal.h>
const int analogInPinA0 = A0; // Use GPIO 34 as the analog input pin A0
const int analogInPinA1 = A1; // Use GPIO 35 as the analog input pin A1
const int digitalInPin = 15; // Use GPIO 15 as the digital input pin
const int ledPin = 40; // Use GPIO 40 to control the LED
LiquidCrystal lcd(8, 9, 4, 5, 6, 7); // RS, E, D4, D5, D6, D7
void setup() {
Serial.begin(115200); // Initialize serial communication
pinMode(digitalInPin, INPUT); // Set the digital input pin as INPUT
pinMode(ledPin, OUTPUT); // Set the LED pin as OUTPUT
lcd.begin(16, 2); // Initialize the LCD
lcd.print("Analog A0: ");
lcd.setCursor(0, 1);
lcd.print("Analog A1: ");
}
void loop() {
int sensorValueA0 = analogRead(analogInPinA0); // Read analog input from pin A0
int sensorValueA1 = analogRead(analogInPinA1); // Read analog input from pin A1
int digitalValue = digitalRead(digitalInPin); // Read digital input from the specified pin
delayMicroseconds(10);
// Map the analog readings to the desired range
int mappedValueA0 = map(sensorValueA0, 0, 8191, 0, 1000);
delayMicroseconds(10);
int mappedValueA1 = map(sensorValueA1, 0, 8191, 0, 14);
delayMicroseconds(10);
lcd.setCursor(11, 0);
lcd.print(mappedValueA0);
lcd.setCursor(11, 1);
lcd.print(mappedValueA1);
// Turn on the LED if the digital input is HIGH
if (digitalValue == HIGH) {
digitalWrite(ledPin, HIGH);
} else {
digitalWrite(ledPin, LOW);
}
delay(1000); // Wait for a second
}