Skip to content

Instantly share code, notes, and snippets.

@lisajamhoury
Created September 23, 2015 01:48
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 lisajamhoury/57a88991a76089ffc8a7 to your computer and use it in GitHub Desktop.
Save lisajamhoury/57a88991a76089ffc8a7 to your computer and use it in GitHub Desktop.
Arduino Analog Input Digital Output
//this is basic code for variable/analog resistor
int ledPin = 2;
int sensorPin = A0;
int sensorValue = 0;
void setup() {
// put your setup code here, to run once:
pinMode(ledPin, OUTPUT);
Serial.begin(9600); //opens connection to the serial monitor
}
void loop() {
// put your main code here, to run repeatedly:
// in my dream code, this would read the pulse
sensorValue = analogRead(sensorPin);
Serial.println(sensorValue); //print line
delay(10); // 10 millisecond delay
// when the pulse rated above a certain frequency it would play the sound of a heartbeat
if (sensorValue < 800) {
digitalWrite(ledPin, HIGH);
}
else {
digitalWrite(ledPin, LOW);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment