Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

SitePoint PHP Blog:
PHP, Arduino, And… Minecraft? Connecting an Arduino to PHP!
Jul 12, 2016 @ 15:39:38

The SitePoint PHP blog has continued their series looking at connecting the real world with the online world via Minecraft and an Arduino. In this new post author Christopher Pitt picks up where he left off in part one and brings the Arduino in to the picture.

In the first part of this series, we learned a bit of Minecraft and the circuitry we can make inside it. We also made a circuit to alert us when the door to our mansion was opened. We then hooked this virtual alarm to a listening PHP script, so we can know when the door is opened in the context of a PHP script.

In this part, we’ll build a small Arduino-based alarm circuit. We’ll learn how to trigger the alarm, using the the official IDE and programming language, and then using something called Firmata. We’ll round the series out by connecting the alarm circuit to the Minecraft circuit, so we hear a real alarm for Minecraft mansion.

He takes some time at the beginning of the post introducing the Arduino hardware and what they have to offer. He lists the parts you'll need for this setup to work and how they need to be set up. He then gets into the code for the Ardunio side and how to get it over to the board. He presents another option to the potentially painful change-reupload cycle of debugging Arduino code: using the PHP "carica/firmata" library to connect to and add listeners to hook into the board. He uses this to then set up a PHP script to watch for changes in the Minecraft log files and fire an event to the waiting Arduino board.

The final item in this part of the tutorial series talks about bringing in the "Gorilla" extension for Carica Firmata to help prevent issues with too fast connections to the board interrupting the boot sequence.

tagged: tutorial series part2 minecraft arduino alarm connecting event loop

Link: https://www.sitepoint.com/php-arduino-and-minecraft-connecting-an-arduino-to-php/

SitePoint PHP Blog:
Hacking the Fitbit – Emulating a Pager for Twitter DMs!
Jun 17, 2016 @ 15:27:57

The SitePoint PHP blog has a tutorial they've posted from Christopher Pitt showing you how to hack your Fitbit into a pager for Twitter DMs. This essentially turns your Fitbit into a notification system for when someone on Twitter sends you a direct message. It's not overly useful (as you can't send a message) but it is an interesting integration.

I’ve been trying to wake up earlier in the morning. The trouble is that alarms wake everybody up, not just me. To get around this problem, I recently bought the cheapest Fitbit I could find, having learned that they have a neat silent alarm.

The truth is, if I had the cash I would rather have bought an Apple watch. When I got the Fitbit, my programmer brain immediately jumped to the question; “How can I hack this thing?” I ended up learning a bit about Fitbit, OAuth and the Twitter API. I also learned that sometimes it’s better just to get an Apple watch…

His application uses Lumen as the framework and makes connections to both the Twitter and Fitbit JSON APIs. He defines a few routes for the OAuth handling (with callbacks) and a simple view with the "Connect To" links. He shows the creation of applications on both the Twitter and Fitbit side and how to define their keys in your configuration. He sets up the Socialite providers for both connections and a bit of caching to prevent the need for a full pull. He then uses the Fitbit API to set "silent alarms" on your device that are timed to go off immediately when the app detects a new DM on the Twitter stream.

tagged: tutorial fitbit twitter api connect application alarm directmessage

Link: https://www.sitepoint.com/hacking-the-fitbit-emulating-a-pager-for-twitter-dms/


Trending Topics: