My-Arduino-Class-Projects/potentiometre_led.ino

22 lines
374 B
Arduino
Raw Permalink Normal View History

2018-05-26 12:54:38 +02:00
int potPin= A0;
int LEDPin= 9;
int readValue;
int writeValue;
void setup() {
pinMode(potPin, INPUT);
pinMode(LEDPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
readValue = analogRead(potPin);
writeValue = (255./1023.) * readValue;
analogWrite(LEDPin, writeValue);
Serial.print("Valeur du potentiometre :");
Serial.println(writeValue);
delay (500);
}