Skip to content

Instantly share code, notes, and snippets.

@rohityadavcloud
Created May 3, 2013 17:38
Show Gist options
  • Save rohityadavcloud/5511771 to your computer and use it in GitHub Desktop.
Save rohityadavcloud/5511771 to your computer and use it in GitHub Desktop.
Arduino hack @wingify, our resident alcohol breathlyzer
int sensorValue;
void setup()
{
Serial.begin(9600); // sets the serial port to 9600
}
void loop()
{
sensorValue = analogRead(0); // read analog input pin 0
int level = map(sensorValue, 500, 780, 0, 10);
if (level < 0)
level = 0;
if (level > 10)
level = 10;
Serial.println(level, DEC); // prints the value read
delay(100); // wait 100ms for next reading
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment