Previously I hooked up a giant whale to the Steem blockchain (currently in wintersleep), but today I found out that the Duplo Steam Train we gave as a Xmas gift to our son, actually has BLE (bluetooth low energy) so I wanted to see if that could be programmable! And of course I wanted it to work with the Steem chain :)
Now it happens to be that there are already many fans building stuff on top of Lego and Duplo peripherals and they all gather on the Eurobricks forums.
This is where I found out that Nathan had already written a Node library which handles all the barebones (bluetooth connection, communications layer) for talking and pushing and receiving events from the Duplo train.
Putting my script together was as simple as hooking Nathan's library together with the dSteem library by @almost-digital and voila... A Steam Train powered by the Steem Chain.
How it works
The node script connects to the Bluetooth of the Duplo Train. As soon as a connection is established, the script will start connecting to the Steem blockchain and streaming blocks as they are pushed to the chain.
Whenever a new block arrives, the script has the light of the train's bumper blink and checks the amount of transactions in the block. If the amount of transactions is higher than the avarage transactions per block, it will speed up the train. If the amount is lower than the average, it will slow down the train.
As a gimmick I also added the "choo choo" whenever my witness @roelandp signs a block.
Here is a demo video
Sources / Links
- My script on github gists: https://gist.github.com/roelandp/e80ccc15bc5317e9704e2ac2b3573f42
- The PoweredUp! Lego node lib: https://github.com/nathankellenicki/node-poweredup#DuploTrainBase
- @almost-digital's dSteem lib: https://github.com/jnordberg/dsteem
- Duplo Steam Train (10874): https://www.lego.com/en-us/themes/duplo/products/steam-train-10874
See you on the chain
If you like what I do, consider supporting my witness @roelandp