From 6fc291a05a488d85e55bf1c8f05aa8f6ae1afb03 Mon Sep 17 00:00:00 2001 From: fanta Date: Wed, 17 Aug 2022 18:10:36 +0200 Subject: [PATCH] =?UTF-8?q?c=C3=B3digo=20para=20arduino=20uno?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- potenciometroVLC.ino | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 potenciometroVLC.ino diff --git a/potenciometroVLC.ino b/potenciometroVLC.ino new file mode 100644 index 0000000..e4f199d --- /dev/null +++ b/potenciometroVLC.ino @@ -0,0 +1,20 @@ +int valor = 0; +int total = 0; +int media = 0; +int posicion; +int i=0; + +void setup() { + Serial.begin(9600); +} +void loop() { + total = 0; + for(i=0; i <= 9; i++){ + valor = analogRead(A0); // Leemos del pin A0 valor + total = total + valor; + } + media = total / i; + // Imprimimos el valor medio por el monitor serie (0 - 1023) + posicion = map(media, 0, 1023, 0, 100); // convertir a porcentaje + Serial.println(posicion); +}