You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
427 B
18 lines
427 B
|
|
|
|
void setup() {
|
|
// initialize serial communication at 9600 bits per second:
|
|
Serial.begin(9600);
|
|
}
|
|
|
|
|
|
void loop() {
|
|
// read the sensor value:
|
|
int sensorValue = analogRead(A0);
|
|
// map the sensor range (0-1023) to a range of 1-100:
|
|
int mappedValue = map(sensorValue, 0, 1023, 0, 100);
|
|
// print the mapped value to the serial port:
|
|
Serial.println(mappedValue);
|
|
// wait a bit for the next reading:
|
|
delay(100);
|
|
}
|
|
|