You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
429 B
C++
21 lines
429 B
C++
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);
|
|
}
|