IFTTT is a service that to create control and connection over the products and apps that you love. In this demo, we will connect two channels, Twitter and Particle Cloud, and create a simple recipe that whenever a new follower to our twitter account (@redbearlab), we will add one and display on a 4 Digital Display.
- - RedBear Duo and RB Link
- - Grove 4 Digital Display
- - IFTTT Account. (if you don't have, just sign up and it is free!)
- - Particle Account
Hardware setup - Use RedBear Duo and RB Link together, and connect Grove 4 digital display to D4 and D5. (or other digital pins on RBLink with Grove cable).
First, create a recipe in your IFTTT account.
While creating recipe, the procedures are:
- Choose a Trigger - select Twitter Channel (you may prompt to connect to your twitter account if you have not done that) in step 1, and select "New Follower" in step 2. Click Create Trigger in step 3.
- Choose Action - Select Particle Channel (you may prompt to connect to your twitter account if you have not done that) in step 4. Select "Publish an event" in step 5.
- Define your Action - We will use Particle Cloud's Publish/Subscribe abilities. In step 6, create a Event Name. We named our event "newfollower". In Data Field, you can apply any data you want to to publish along with this event when there is new follower. In our case, we just send an String "add".
- Click Create Action. In Step 7, name your recipe and click create Recipe.
Now your IFTTT recipe is ready.
Power on RedBear Duo if you have not. Make sure RGB LED is breathing cyan (connected to Particle Cloud Status).
Login Particle and click build to start Particle's Web IDE
In Web IDE, Make sure that you select RedBear Duo as a target device.
Create a new App and add TM1637Display Library to the project.
Then copy the following code and paste it in your new App.
[gist id="450529030c044cf9d770" file="IFTTT-newFollower.ino"]
Compile and flash your Duo, and when you see the RGB LED is cyan breathing again, it is IFTTT ready with less than 30 lines of code!
Whenever there is a new Twitter follower, you will see the number on 4 digital display increase by one(It may take sometime for you to see a new follower).
- Currently, if someone unfollowed(please no~), you would not see decrement because we did not implement it. However, it is easy to apply your own logic here.
- What if more than 9999 followers? You may see missing figure.
- Improvement? To make it more fun, may add a buzzer buzzing when a new follower follows. Use Maker Channel and your own scrapping method to get the correct number of followers. Change to LCD Display. etc.
- So, what will you make today? :)
Hope you enjoy this Demo and have fun! Follow @redbearlab now to trigger our IFTTT recipe!