Every inventor began with one small project. Pick one and bring your idea to life today!
Great inventors and great teachers all started with one small step. Take yours today!
The same kits we use in 40+ school labs โ grab yours and build something youโre proud of.
Log in to continue
Every TinkerPy program is built like a house: the toolboxes at the door (import), name tags on every pin, a start-up room that you pass through once (setup) and a room where the action never stops (loop). Learn the plan once and every program becomes easy to read!
Switches on a library โ an extra toolbox of functions, like import buzzer or import servo. Import lines go at the very top.
A friendly name for a pin: o1 = set_name("lamp"). After that you write lamp instead of o1 everywhere.
Text after a #. The board ignores it โ it is a note for people. TinkerPy adds one for you when you press Enter.
The block that runs only once, when the board starts: pin settings and one-time jobs like a start-up beep.
The block that runs again and again, forever. When it reaches the end, it starts again from the top of loop.
The 4 spaces at the start of a line. Indented lines belong to the block above them (setup:, loop:, if โฆ).
Press Play. Watch setup run once (the start-up beep), then loop run again and again.
Tap โUse namesโ and watch pin numbers turn into plain-English names.
# Add the libraries you need import oled_display # ===== My TinkerPy Project ===== # This code block executes only once setup: oled_begin() # starts the OLED o7 = set_function(SDA) # cannot be changed o8 = set_function(SCL) # cannot be changed # This code block executes forever loop:
A brand-new project looks like this. The OLED screen is switched on, so its import line and its three setup lines are already there; setup: and loop: are waiting for your code. Circuit Connections pops up straight away so you can add your parts.
# Add the libraries you need import buzzer # Give your pins easy-to-remember names o1 = set_name("light") o2 = set_name("beeper") # ===== Hello beep ===== # This code block executes only once setup: light = set_output(led) beeper = set_output(buzzer) # beep once at start beeper = ON # turn beeper ON wait(300) # pause here for 300 milliseconds before continuing beeper = OFF # turn beeper OFF # This code block executes forever loop: light = ON # turn light ON
Start-up hello beep: the buzzer named beeper (o2) beeps once in setup, then loop keeps the LED named light (o1) on. Picking the buzzer added import buzzer at the top. The # beep once at start line is our own comment; the others appeared when we pressed Enter.
# Add the libraries you need import buzzer # Give your pins easy-to-remember names o1 = set_name("beam") o2 = set_name("horn") # ===== Lighthouse ===== # This code block executes only once setup: beam = set_output(led) horn = set_output(buzzer) # one long horn when the lighthouse wakes up horn = ON # turn horn ON wait(1000) # pause here for 1000 milliseconds before continuing horn = OFF # turn horn OFF # This code block executes forever loop: # a short flash, then a long dark gap beam = ON # flash! wait(200) # pause here for 200 milliseconds before continuing beam = OFF # turn beam OFF wait(1800) # dark for almost 2 seconds
A fully labelled program with all five parts: import, pin names, title, setup and loop. The lines โ# one long horn โฆโ and โ# a short flash โฆโ, plus โflash!โ and โdark for almost 2 secondsโ, were written by hand. Tip: TinkerPy keeps comments on their own line; for your own words at the end of a line, change the automatic comment after you press Enter.
setup: wake up, brush your teeth. loop: breathe, blink, listenโฆ you never stop those!
On the first day of school, name tags make it easy to call people. Pin names do the same for your code.
Programmers spend more time reading code than typing it โ good names and comments save hours.
Pick an LED on o1 (name it light) and a buzzer on o2 (name it beeper). In setup, make the buzzer beep once; in loop, keep the LED on. Run it in the Simulator, then move the beep into loop and see what changes.
๐งฐ You need: TinkerPy Code (Simulator)Take the Lighthouse program and write your own comment on every line you typed, plus one section comment at the top of setup and loop. Ask a friend to read only the comments and guess what the gadget does.
๐งฐ You need: TinkerPy Code, a friendWhen a loop has no wait(), the board can run it many thousands of times every second โ far faster than you can blink!
5 quick questions to check yourself โ free with your TinkerPy account.
Log in