Last active
July 15, 2016 10:07
-
-
Save dyadica/0c9a37433141b83e6786044889865a6b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int sensorPin = A0; | |
void setup() | |
{ | |
Serial.begin(9600); | |
} | |
void loop() | |
{ | |
int sensorReading = analogRead(sensorPin); | |
// Output the raw sensor reading | |
Serial.println(sensorReading); | |
// Using map(); convert to a range like 0-100. Use the | |
// raw values to determine the from values (0,975) | |
int sensor0to255 = map(sensorReading, 0, 975, 0, 255); | |
Serial.println(sensor0to255); | |
// Slow down the output for easier reading | |
delay(250); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment