Project 02
Read the potentiometer
The code.
//Declare
const int POT_PIN = A0; // Potentiometer connected to Analog Pin A0
//Setup
void setup() {
Serial.begin(9600); // Init serial comm at 9600 bits per second
pinMode(POT_PIN, INPUT); //Setup pot-pin
}
//Run
void loop() {
void loop() {
int potValue = analogRead(POT_PIN); // Read pot value (Analog : 0 to 1023)
printPotVal(potValue); // Print value to Serial Monitor
delay(100); // Delay for visibility
}
//Logic
void printPotVal(int potVal){
Serial.print("Pot Value: ");
Serial.println(potVal);
}