Monday, November 16, 2009

Entradas Analogas + comunicación serial

Usamos un potenciometro de 10k para ver el funcionamiento los puertos análogos. También el el código nos comunicamos de forma serial con nuestro PC, pudiendo observar los datos en la escala de 0 a 1023.





int potPin = 0; // select the input pin for the potentiometer
int val = 0; // variable to store the value coming from the sensor

void setup() {

Serial.begin(9600);
}

void loop() {
val = analogRead(potPin); // read the value from the sensor
Serial.print(val);
Serial.print(" ");
delay(200);
}

No comments:

Post a Comment