Skip to content

Instantly share code, notes, and snippets.

@joselynNeon
Forked from julioterra/analog_sensor.ino
Created February 19, 2014 01:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joselynNeon/9084514 to your computer and use it in GitHub Desktop.
Save joselynNeon/9084514 to your computer and use it in GitHub Desktop.
void setup() {
// open serial port
Serial.begin(9600);
}
void loop() {
// read and send the value of analog sensor
long raw_val = analogRead(A0);
// use to adjust the range, if necessary
// int range_offet = 3;
// int range_size = 60;
// raw_val = raw_val - range_offet;
// raw_val = constrain( (raw_val * 1023 / range_size), 0, 1023);
Serial.println(raw_val);
// wait to send the next value so that you
// don't clog up the serial port
delay(100);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment