unsigned long time;
void setup() {
Serial.begin(115200); // establishes a connection between the arduino and the computer screen - allows text to show
pinMode(A0, INPUT); // configures the pin to behave as an input or an output
pinMode(LED_BUILTIN, OUTPUT);
pinMode(5, INPUT);
}
void loop() {
int pot_value = analogRead(A0);
int switch_value = digitalRead(5); //reads the value of the potentiometer - the potentiometer is connected to A0
Serial.print(pot_value); // prints the value that has been read onto the screen
Serial.print(", ");
Serial.print(switch_value);
Serial.print(". ");
Serial.print("Time: ");
time = millis();
Serial.println(time);
delay(100); // prints the value, waits 100 ms, then prints the next value reading
}
// the lowest value is 0 and the highest is 1023
// this is because the analogue input is an 10 bit. 2^10 = 1024
// start reading from 0, hence the highest value is 1023