-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVariableBlink-Serial
More file actions
38 lines (29 loc) · 1.08 KB
/
Copy pathVariableBlink-Serial
File metadata and controls
38 lines (29 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*
Blink with variable frequency
Turns on an LED on for x seconds, then off for x seconds, repeatedly.
x is given by variable resistor:
* left and right pins of resistor to respectively +5V to analog and 0
* Middle Pin to A0
*/
// Pin 13 has an LED connected on most Arduino boards.
// Pin 11 has the LED on Teensy 2.0
// Pin 6 has the LED on Teensy++ 2.0
// Pin 13 has the LED on Teensy 3.0
int led = 13; // output of the LED
int thisSensor = 0; // input A0 of the resistor
// the setup routine runs once when you press reset:
void setup() {
//start serial connection
Serial.begin(9600);
// initialize the digital pin as an output.
pinMode(led, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
int sensorReading = analogRead(thisSensor);
Serial.println(sensorReading);
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(sensorReading); // wait for a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(sensorReading); // wait for a second
}