int ledPin1 = D2;
int ledPin2 = D0;
int buzzer = D3;
int buttonPin = D1;
bool isMediating = false;
long mediationStartTime = -1;
void setup()
{
pinMode( buttonPin , INPUT_PULLUP); // sets pin as input
pinMode( ledPin1 , OUTPUT ); // sets pin as output
pinMode( ledPin2 , OUTPUT );
digitalWrite( ledPin1, LOW);
digitalWrite(ledPin2, LOW);
}
void loop()
{
// find out if the button is pushed or not by reading from it.
int buttonState = digitalRead( buttonPin );
// switch LED color to signify timer starting
if( isMediating == false && buttonState == LOW )
{
// read temp of dht and display
tempReading = analogRead(DHTPIN);
// blink blue LED to signify starting timer
digitalWrite(ledPin2, LOW);
digitalWrite(ledPin1, HIGH);
delay(500);
digitalWrite(ledPin1, LOW);
delay(500);
digitalWrite(ledPin1,HIGH);
delay(500);
digitalWrite(ledPin1,LOW);
// start the mediation cycle...
isMediating = true;
// keep a track of when we started meditating
mediationStartTime = millis();
}else{
// otherwise turn white led on during meditation session
digitalWrite( ledPin2, HIGH);
}
// update the start
isMediating = false;
mediationStartTime = -1;
}
// turn off both lights
if ( isMediating == false ) {
digitalWrite(ledPin1,LOW);
digitalWrite(ledPin2, LOW);
}
// anything less than 10 minutes, white light is on
else {
digitalWrite(ledPin2, HIGH);
}
}
Click to Expand
Content Rating
Is this a good/useful/informative piece of content to include in the project? Have your say!
You must login before you can post a comment. .