#include <LiquidCrystal_I2C.h>
float input() {
while (Serial.available()==0);
{
return Serial.parseFloat();
}
}
#define I2C_ADDR 0x27
#define LCD_COLUMNS 16
#define LCD_LINES 2
const int Pinpwm = 10;
long puissance;
LiquidCrystal_I2C lcd(I2C_ADDR, LCD_COLUMNS, LCD_LINES);
void setup() {
// put your setup code here, to run once:
pinMode(Pinpwm, OUTPUT);
lcd.init();
lcd.backlight();
// Print something
lcd.setCursor(0, 0);
lcd.print("Hello, world!");
lcd.setCursor(0, 1);
lcd.print("Wokwi Online IoT");
delay(1000);
lcd.clear();
}
void loop() {
// put your main code here, to run repeatedly:
//affichage de la valeur du potentiomètre et du pwm équivalent
lcd.setCursor(0, 0);
lcd.print("Pot =");
lcd.print(analogRead(A0));
lcd.print(" ");
puissance = analogRead(A0)*256/1024;
lcd.setCursor(0, 1);
lcd.print("PWM =");
lcd.print(puissance);
lcd.print(" ");
//ecriture sortie PWM
analogWrite(Pinpwm, puissance);
}