Menu

Arduino YÚN YouTube Sign! (First YÚN Project)

With the power of the Arduino YÚN, I made an LCD sign that displays the number of subscribers of the famous YouTube user Pewdiepie’s channel! The led also glows blue if he’s put up a new video in the last hour! Awesome!

Sorry there haven’t been many posts up lately, I’ve been very busy and haven’t had any electronics time :(. But now that a four day weekend has rolled around (\o/) I can get back to what I love! Ok, to this Arduino business. It all started when I won a twitter competition put on by MCMElectronics over the Arduino Day weekend by retweeting the competition tweet and entering in a drawing for 3 Arduino UNOs and one grand prize YÚN. On the last day, I ended up winning the ~$85 WIFI connected linux board and after it arrived yesterday, I’ve been very busy with it.

Tutorial

Since this is so cool, and it’s a perfect way to explain how I did it, I’m going to do a how-to guide on how you can set this project up yourself! You can change the channel to any one you wish, and customize the message too!

With the YÚN comes an amazing partner service called Temboo. Temboo is a compiled programming environment that brings together the APIs of over one hundred different internet services in one place, and provides easy to use tools and code generators to help you reach out into the web using the YÚN to take advantage of these complicated services and make them easier for people to use. In this project, I took advantage of Google’s YouTube API which offers you many different things to do with YouTube videos, channels, statistics, playlists, trends, you name it. I selected the area closest to what I wanted to do, display Pewdie’s subscriber count, which ended up being “ListChannelsByID” which when queried, returns data from Google like this:

In essence, what my program does is it takes in this long message from Google, finds what position in the message the word “subscriberCount” ends and “hiddenSubscriberCount”begins, trims the message to just the number of subscribers, and then prints it on the LCD screen. The number of videos from “videoCount” is also read, and if the number changes in the span of one hour indicating a new video, the blue LED turns on! Cool!

Hardware

For this project you’ll need these supplies (beautiful pictures by Adafruit, YÚN photo by me!):

Wiring

To wire up the circuit, attach the LCD in the standard fashion with the trimpot and the backlight connected as per this diagram:

Next, plug the LED’s positive leg into pin D13, and the shorter one into GND in the top left of the diagram.

Ok, with everything wired up you can plug the YÚN in and the screen should show a contrast calibration pattern to which you can dial the potentiometer to a setting you are comfortable with. If not, check those pesky connections, there are a lot of wires to get right!

Software

First thing’s first, in order to have YÚN compatibility, the Arduino IDE must be v1.5.6 or later, which can be downloaded from here.

After that, go ahead and make a Temboo account if you haven’t already, and get that all set up here. With that complete, we need authorization codes from Google in order to use the YouTube API. Just follow the setup instructions from Temboo about what codes you need from where, and how to generate them here. Follow all instructions from Google in the Developer’s Console and generate the codes needed in the setup instructions. KEEP THEM SAFE!

In another Arduino tab that you’ll name “TembooAccount.h,” paste this code in, and fill in your Temboo account information in the right places.

/*
IMPORTANT NOTE about TembooAccount.h
TembooAccount.h contains your Temboo account information and must be included
alongside your sketch. To do so, make a new tab in Arduino, call it TembooAccount.h,
and copy this content into it.
*/
#define TEMBOO_ACCOUNT "accountName" // Your Temboo account name
#define TEMBOO_APP_KEY_NAME "myFirstApp" // Your Temboo app key name
#define TEMBOO_APP_KEY "abc123xxxxxxxxxxxxxx" // Your Temboo app key
/*
The same TembooAccount.h file settings can be used for all Temboo SDK sketches.
Keeping your account information in a separate file means you can share the
main .ino file without worrying that you forgot to delete your credentials.
*/

With that complete, compile and check for errors. If you’re error free, upload it to the YÚN when it’s connected to the internet via ethernet or WIFI, and watch the numbers update live with Pewdie’s subscriber count! Awesome!

Customization

In order to customize this project to a different channel, simply go to this link, scroll to the bottom, under the Try it! heading, in the “id” entry, type “statistics,” and in the “forUsername” entry, type whoever you’d like to display. Hit execute, and in the response block you get back, find the channel id and exchange it with Pewdie’s in the program.

To change the message, for the first line’s text, switch out “Pewdiepie’s Bro ” for something else, and likewise for “Army:”

Conclusion

If everything runs smoothly, you should now have a YouTube sign that indicates when new videos are uploaded by the channel, and displays the subscriber count in real time! I certainly had great fun building this, and as my first YÚN project, it’s opened the doors to so many awesome things from Temboo! Amazon has an API, USPS, Paypal, Instagram, and many other common services do too! The possibilities are endless!