Terminal widget using raspi

Depends on the programming language you are using on the Pi.

See the above link for C++ (WireingPi)

And this is using NodeJS…

I haven’t tried the Terminal Widget in Python yet, so no idea.