Hackster is hosting Hackster Holidays, Ep. 6: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Monday!Stream Hackster Holidays, Ep. 6 on Monday!
Yatin Agarwal
Published © GPL3+

Button Operated Email Sender

Press a button, send an email, as easy as it gets. Photon + IFTTT.

BeginnerFull instructions provided1 hour3,192
Button Operated Email Sender

Things used in this project

Story

Read more

Code

Email_sender

Arduino
Sends email by pressing a push button.
int led = D7; // Uses inbuilt LED
int pushButton = D1; // Push button is connected to D1

// This routine runs only once upon reset
void setup() 
{
  pinMode(led, OUTPUT); // Initialize D7 pin as output
  pinMode(pushButton, INPUT_PULLUP); 
  // Initialize D1 pin as input with an internal pull-up resistor
}

// This routine loops forever
void loop() 
{
  int pushButtonState; 

  pushButtonState = digitalRead(pushButton);

  if(pushButtonState == LOW)
  { // If we push down on the push button
    digitalWrite(led, HIGH);  // Turn ON the LED
    Spark.publish("pushButtonState","Pressed",60,PRIVATE);
    // Add a delay to prevent getting tons of emails from IFTTT
    delay(5000); 
  }
  else
  {
    digitalWrite(led, LOW);   // Turn OFF the LED 
  }

}

Credits

Yatin Agarwal

Yatin Agarwal

0 projects • 1 follower
Founder at selfcure.co. A coding, chess, math, design, animation, music, cooking, and writing enthusiast.

Comments