Advertisement
iyed

Untitled

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