Advertisement
iyed

Untitled

May 11th, 2021
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. #include<LiquidCrystal.h>
  2.  
  3. const int analogInPin = A0; // La broche d’entrée analogique à laquelle le potentiomètre est relié
  4. const int analogOutPin = 9; // La broche peusdo-analogique à laquelle est reliée la LED
  5. int sensorValue = 0; // La valeur lue sur le potentiomètre
  6. int outputValue = 0; // La valeur générée sur la broche PWM
  7.  
  8.  
  9. LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16. void setup() {
  17.  
  18. pinMode(analogInPin, INPUT);
  19. pinMode(analogOutPin, OUTPUT);
  20. Serial.begin(9600);
  21.  
  22. lcd.begin(16, 2);
  23.  
  24.  
  25.  
  26. }
  27.  
  28. void loop() {
  29.  
  30. sensorValue = analogRead(analogInPin);
  31. outputValue = map(sensorValue, 0, 1023, 0, 255);
  32. analogWrite(analogOutPin, outputValue);
  33.  
  34.  
  35. lcd.setCursor(0,0);
  36. lcd.print("SensorValue= ");
  37. lcd.print(sensorValue);
  38. lcd.setCursor(0,1);
  39. lcd.print("OutputValue= ");
  40. lcd.print(outputValue);
  41.  
  42.  
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement