EasyManua.ls Logo

Keyestudio ESP32 - Page 166

Keyestudio ESP32
344 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
ESP32 Starter Kit
(continued from previous page)
if (distance < 10) { //Eliminate the second residual digit when the value drops to
˓one digit
lcd.setCursor(10, 1);
lcd.print(" ");
}
}
void show_luminance() { //Read the analog value of photoresistor
int value = analogRead(ligth_sensor);
lcd.setCursor(0, 1);
lcd.print("Luminance:");
lcd.setCursor(11, 1);
lcd.print(value);
if (value < 1000) {
lcd.setCursor(14, 1);
lcd.print(" ");
}
if (value < 100) {
lcd.setCursor(13, 1);
lcd.print(" ");
}
if (value < 10) {
lcd.setCursor(12, 1);
lcd.print(" ");
}
}
void show_sound() { //Read the analog sound value
int value = analogRead(sound_sensor);
lcd.setCursor(0, 1);
lcd.print("Sound:");
lcd.setCursor(7, 1);
lcd.print(value);
if (value < 1000) {
lcd.setCursor(10, 1);
lcd.print(" ");
}
if (value < 100) {
lcd.setCursor(9, 1);
lcd.print(" ");
}
if (value < 10) {
lcd.setCursor(8, 1);
lcd.print(" ");
}
}
void show_pot() { //Read the analog value of potentiometer
int value = analogRead(pot_sensor);
lcd.setCursor(0, 1);
lcd.print("PotAnalog:");
lcd.setCursor(11, 1);
(continues on next page)
162 Chapter 8. Arduino Tutorial

Table of Contents