Created
September 23, 2015 01:48
-
-
Save lisajamhoury/57a88991a76089ffc8a7 to your computer and use it in GitHub Desktop.
Arduino Analog Input Digital Output
This file contains 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
//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