Skip to content

Instantly share code, notes, and snippets.

@ErikABengtsson
Last active February 16, 2017 18:52
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 ErikABengtsson/2246b1d3a6505ed77e61637ff323346c to your computer and use it in GitHub Desktop.
Save ErikABengtsson/2246b1d3a6505ed77e61637ff323346c to your computer and use it in GitHub Desktop.
Concentration_Light
/*
Concentration Alarm
Erik Bengtsson
GDES-3013-001 Wearable computing
OCAD University
Created on February 15th 2017
Based on:
Button, DojaDave <http://www.0j0.org>
*/
/*
Concentration alarm
Turns off blinking light emitting diode(LED) connected to
pin 6, when activating a bridge switch attached to digital pin 13.
The circuit:
* Bridge switch and 10k resistor attached to pin 13 from +3V
* LED and 330ohm resistor attached to pin 6 from +3V
created 2017
by Erik Bengtsson
*/
// constants won't change. They're used here to
// set pin numbers:
const int buttonPin = 13; // the number of the pushbutton pin
const int ledPin = 6; // the number of the LED pin
// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
void setup() {
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
}
void loop() {
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);
// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonState == HIGH) {
// turn LED on:
digitalWrite(ledPin, HIGH);
} else {
// turn LED off:
digitalWrite(ledPin, LOW);}
if(buttonState == LOW)
//makes the light blink:
{digitalWrite(ledPin, HIGH);
delay(80);
digitalWrite(ledPin, LOW);
delay(80);
}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment