const int buttonPin = 2; // the number of the pushbutton pin
const int ledPin = 13; // the number of the LED pin
int pirPin = 7;
int minSecsBetweenE mails = 60; // 1 min
long lastSend = -minSecsBetweenE mails * 1000l;
// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
int led = 12
void setup() {
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonP in, INPUT);
//initalize the digital pin as an output
pinMode(led, OUTPUT);
}
void loop(){
// read the state of the pushbutton value:
buttonState = digitalRead(but tonPin);
// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonState == HIGH) {
// turn LED on:
digitalWrite(le dPin, HIGH);
}
else {
// turn LED off:
digitalWrite(le dPin, LOW);
}
{
long now = millis();
if (digitalRead(pi rPin) == HIGH)
{
if (now > (lastSend + minSecsBetweenE mails * 1000l))
{
Serial.println( "MOVEMENT") ;
lastSend = now;
}
else
{
Serial.println( "Too soon");
}
}
delay(500);
digitalWrite(le d, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(le d, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
}
const int ledPin = 13; // the number of the LED pin
int pirPin = 7;
int minSecsBetweenE mails = 60; // 1 min
long lastSend = -minSecsBetweenE mails * 1000l;
// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
int led = 12
void setup() {
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonP in, INPUT);
//initalize the digital pin as an output
pinMode(led, OUTPUT);
}
void loop(){
// read the state of the pushbutton value:
buttonState = digitalRead(but tonPin);
// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonState == HIGH) {
// turn LED on:
digitalWrite(le dPin, HIGH);
}
else {
// turn LED off:
digitalWrite(le dPin, LOW);
}
{
long now = millis();
if (digitalRead(pi rPin) == HIGH)
{
if (now > (lastSend + minSecsBetweenE mails * 1000l))
{
Serial.println( "MOVEMENT") ;
lastSend = now;
}
else
{
Serial.println( "Too soon");
}
}
delay(500);
digitalWrite(le d, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(le d, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
}
Comment