unsigned long time = 0; //creates time variable
void setup() {
Serial.begin(115200); //starts serial communication and puts it at speed 115200bps
pinMode(A0, INPUT); //sets potentiometer pin to an input
pinMode(5, INPUT_PULLUP); //sets up switch pin
delay(1000); //delays so that headers can be printed
Serial.println("Potentiometer, Switch, Time"); //headers
}
void loop() {
int value = analogRead(A0); //reads value of sensor
int switch_value = digitalRead(5); //reads value of switch
time = millis(); //value of time since program started running
Serial.print(value); //prints value of sensor
Serial.print(" "); //puts space between two pieces of info
Serial.print(switch_value); //prints value of switch
Serial.print(" "); //puts space between two pieces of info
Serial.println(time); //prints current value of time
delay(100); //delays going back to beginning of loop
}
//min 0, max 1023 because 5V potentiometer and so has 1024 bit resolution