From blocks to Arduino C++: TinkerPie Build & Flash
Every block program in TinkerPie Studio is also shown as an Arduino C++ sketch for the TinkerPie Arduino library. It is the natural next step after blocks and JavaScript.
Example
#include <TinkerPie.h>
using namespace tinkerpie;
void setup() {
tinkerpie::begin();
input::onButtonPressed(Button::A, []() {
basic::showIcon(IconNames::Heart, Colors::Red);
});
}
void loop() {
tinkerpie::loop();
}
Why C++ after blocks?
Blocks are the fastest way to start: you cannot make a spelling mistake and every block fits only where it makes sense. C++ is what engineers use on real products. Seeing the same program in both forms shows students that each block is a line of code: when button A pressed becomes input::onButtonPressed(Button::A, ...), and show icon becomes basic::showIcon(...).
What is in the sketch
#include <TinkerPie.h>loads the TinkerPie Arduino library: matrix, buttons, buzzer, motors, servos and sensors.setup()runs once when the board starts.tinkerpie::begin()must come first.loop()runs again and again.tinkerpie::loop()keeps the buttons, sensors and events working.
Upload it from the browser
In Block Coding, press Upload to open your blocks as C++ in Hardware Programming. There, press Upload again: the website compiles the sketch with the official ESP32 Arduino tools and writes it to your TinkerPie V1 over USB, in Chrome or Edge. See Upload Arduino code from your browser for the full steps. The same works for Arduino UNO, Nano and ESP32 boards.
Prefer the Arduino IDE?
Press Download in Hardware Programming to get the .ino file, and add the TinkerPie library (Sketch > Include Library > Add .ZIP Library). Board: ESP32S3 Dev Module, USB CDC On Boot: Enabled, Flash Size: 16MB, PSRAM: OPI PSRAM. The TinkerPie Studio launcher on a computer also has Build & Flash in its Arduino C++ tab.