Amr Saleh
Published © CC0

Tweet from Arduino through your smartphone

In this tutorial, you will post a tweet with a push of a button through Arduino.

BeginnerShowcase (no instructions)1,245
Tweet from Arduino through your smartphone

Things used in this project

Story

Read more

Schematics

Twitter tutorial.fzz

Code

Twitter Shield Example

Arduino
/*

Twitter Shield Example

This example shows an application on 1Sheeld's Twitter shield.

By using this example, you can tweet each time you press
the hardware push button placed on pin 12.

OPTIONAL:
To reduce the library compiled size and limit its memory usage, you
can specify which shields you want to include in your sketch by
defining CUSTOM_SETTINGS and the shields respective INCLUDE_ define. 

*/

#define CUSTOM_SETTINGS
#define INCLUDE_TWITTER_SHIELD

/* Include 1Sheeld library. */
#include <OneSheeld.h>

/* A name for the button on pin 12. */
int buttonPin = 12;
/* A name for the LED on pin 13. */
int ledPin = 13;

void setup() 
{
  /* Start communication. */
  OneSheeld.begin();
  /* Set the button pin as input. */
  pinMode(buttonPin,INPUT);
  /* Set the LED pin as output. */
  pinMode(ledPin,OUTPUT);
}

void loop()
{
  /* Always check the button state. */
  if(digitalRead(buttonPin) == HIGH)
  {
    /* Turn on the LED. */
    digitalWrite(ledPin,HIGH);
    /* Tweet. */
    Twitter.tweet("I'm tweeting from @Arduino via @1Sheeld!");
    /* Wait for 300 ms. */
    OneSheeld.delay(300);
  }
  else
  {
    /* Turn off the LED. */
    digitalWrite(ledPin,LOW);
  }
}

Codebender

Credits

Amr Saleh

Amr Saleh

3 projects • 57 followers
Maker, Breaker, sometimes Fixer, Husband, one of the creators of 1Sheeld & Elkrem tools.

Comments