Simple way to integrate Twitter to your projects using Photon and IFTTT

The folks at Particle (erstwhile Spark) are awesome – they make great IoT products and are really super nice people. They gifted Omkar a Photon at the MakerFaire. His summer break just started and this was his priority #1.

Omkar wanted a way to know when someone mentions or follows @IoT4Kids. Particle makes this incredibly easy to do with just a few lines of code. You essentially can make any action happen (light up or move something and/or make some noise) based on Twitter activity using their Arduino compatible WiFi integrated micro-controller and their integration with IFTTT.

This simple example lights up an LED.

BTW, the display box is 3D printed using Printrbot Simple which is another awesome product for kids to get started with 3D printing.

This is all made so easy with the Particle Spark.Function() that is triggered ‘automagically’ 🙂 from IFTTT. All you need is the code below and create a recipe with Twitter trigger and Particle action.


int ledpin = D7;
void setup()
{
// register the cloud function
Spark.function("tweet", twittermessage);
pinMode(ledpin, OUTPUT);

}

void loop()
{
delay(5000);
digitalWrite(ledpin, LOW);
delay(5000);
}

// this function automagically gets called upon a tweet mention
int twittermessage(String ignore)
{
digitalWrite(ledpin, HIGH);
return(0);
}

Here is a more fun example of this by Brian Sherwin. He also has an example of making this with your own node.js application to make the action trigger immediately instead of the 15 min cycle on IFTTT.

So folks, if you liked this please follow or mention @IoT4Kids and light up Omkar’s day. :).

Advertisements