powered by TinkerSpace.in
Join free
TinkerPy Tutorial ๐Ÿ“˜ Part 1 ยท Starter ยท Chapter 2 of 24

IDE, Compiler, Simulator & Upload

Real programmers have a workshop full of tools โ€” and so do you! In TinkerPy Code you write your program, the compiler checks it, the simulator runs it on a virtual board and Upload sends it to your real board over WiFi or Bluetooth.

๐Ÿ“–Key words

IDE

Integrated Development Environment: one app with every tool for coding โ€” editor, checker, tester and uploader. TinkerPy Code is your IDE.

Compile

Checking every line of your code and turning it into machine code the board understands. Simulator and Upload open only after a good Compile.

Compile error

A problem the compiler cannot fix by itself. It is shown in red on that line: ERROR: โ€ฆ, with the line number in the red bar at the bottom.

Auto-correct

Small slips (a capital letter, = instead of ==, a missing colon) that Compile fixes for you and explains in yellow: AUTO_CORRECT: โ€ฆ

Simulator

A virtual board on your screen. Press buttons, move sliders and watch LEDs, buzzers and motors โ€” no hardware needed.

Upload

Sending the compiled code to your board, over WiFi (Device ID + board password) or Bluetooth (board close by, TinkerPy Mega).

๐ŸŽฌSee it work

The journey of a program

Press play or tap each step to follow a program from your screen to the board.

WiFi or Bluetooth upload?

Switch between the two ways of uploading and read what each one needs.

๐Ÿง How it works

A tour of the TinkerPy Code IDE

  • CODE LIBRARY (the tab on the left): every TinkerPy function with examples, in groups like Control flow, Loop and Output Function โ€” tap one to add it to your code.
  • Circuit Connections (the round green chip button on the code): tap a pin โ†’ pick what is connected โ†’ name it. The setup lines are written for you.
  • Top bar: File / โ˜ฐ menu (New Project, Open Project, Example Projects, Save As, Publish to AppSpaceโ€ฆ), Save (it also saves by itself), i = Information window, โ˜… parameter hints, # comments, Undo / Redo, and the device: Mega or Mini.
  • The three big buttons: Compile, Simulator and Upload. On a phone, use the round + Quick menu and the small Compile button next to it.
  • Helpers: Tinku, the AI teacher, explains your code out loud line by line ยท type .. for the Magic Code Creator (pick a function, fill the boxes, it writes the line) ยท type ?? at the end of a line to have it explained.

Compile: check, auto-correct, explain

  • Press Compile first, every time. It checks every line for the board you chose (Mega or Mini).
  • Small slips are fixed for you and explained in yellow: If โ†’ if, = โ†’ == in a question, a missing :, a ; removed, wait(2s) โ†’ wait(2000).
  • Real mistakes show in red on their line โ€” ERROR: Unknown function 'wiat(...)' โ€” with a red dot, and the bar at the bottom says 1 error โ€” line 18: โ€ฆ
  • Often you get help: SUGGESTIONS: did you mean 'wait'? or Pick one buttons that put in the fix and compile again. Tap a note to see your comments again.
  • All good? โœ“ Compile Success โ€” Simulate or Upload now. On a phone the Compile button turns green (Compile Success) or red (Compile Error).

Simulator and AI Simulation

  • The Simulator runs your code on a virtual board. A widget appears for each pin and device your code uses, with the names you gave them.
  • Press Run. Press an inputโ€™s button (or HOLD it down), drag sliders for sensors, and watch LEDs, buzzers, servos and motors react. A wait(500) takes half a second, just like on the board.
  • Edit lets you move and resize widgets; choose Widgets (place them anywhere) or Block diagram (every widget in its place around the board).
  • โœจ AI Simulation puts your code and the simulation side by side: the running line glows, values of pins and variables show, and each if line gets a yes / no badge. Use ๐Ÿ‘ฃ Step, ๐Ÿข Slow, โšก Normal and Next line.

Upload to your board

  • Press Upload โ†’ the Upload to TinkerKit box opens. Choose WiFi or Bluetooth.
  • WiFi: type the Device ID (the 10 characters printed on your board, like TP00000001) or pick a board you used before, and the 4-digit board password shown on the boardโ€™s CODE DOWNLOAD screen. Press Verify & Upload.
  • The code waits on tinkerpy.com and an online board picks it up by itself. If it is offline, switch it on and press Code download in its menu.
  • Bluetooth (TinkerPy Mega): on the board choose Menu โ†’ Download via BT, keep it close, choose TinkerPy TPโ€ฆ in the Bluetooth list and enter the password.
  • Success: Code uploaded! and CODE DOWNLOADED โ€” your program is running on the board.

๐Ÿ’ปCode

Text
# Give your pins easy-to-remember names
i1 = set_name("button")
o1 = set_name("lamp")

# ===== Button lamp =====

# This code block executes only once
setup:
    button = set_input(push_button, active_low)
    lamp = set_output(led)

# This code block executes forever
loop:
    If button = ON
        lamp = ON;
    else:
        lamp = OFF
    wiat(100)

Fix-the-bug challenge: this button lamp was typed in a hurry. Can you spot all five mistakes before you press Compile? Look at lines 14, 15 and 18.

Text
14    if button == ON:     โš  AUTO_CORRECT: Fixed capital letters (TinkerPy words are lowercase; ON/OFF are capitals); Changed '=' to '=='; Added missing ':'
15        lamp = ON        โš  AUTO_CORRECT: Removed ';' (TinkerPy doesnโ€™t need it)
16    else:
17        lamp = OFF
18    wiat(100)            โ— ERROR: Unknown function 'wiat(...)'.   Pick one: wait(โ€ฆ)

Red bar at the bottom:   1 error โ€” line 18: Unknown function 'wiat(...)'.

What Compile shows. Four slips were fixed by themselves (yellow AUTO_CORRECT notes on lines 14 and 15). One real error is left on line 18: wiat is not a TinkerPy word. Tap the Pick one button wait(โ€ฆ) or fix the spelling yourself, then press Compile again.

# Give your pins easy-to-remember names
i1 = set_name("button")
o1 = set_name("lamp")

# ===== Button lamp =====

# This code block executes only once
setup:
    button = set_input(push_button, active_low)
    lamp = set_output(led)

# This code block executes forever
loop:
    if button == ON:  # when button is ON
        lamp = ON  # turn lamp ON
    else:  # otherwise
        lamp = OFF  # turn lamp OFF
    wait(100)  # pause here for 100 milliseconds before continuing

The fixed program after a second Compile: Compile Success! Now press Simulator, then Run, and press or HOLD the button widget to light the lamp. When it works, press Upload.

Open TinkerPy Code

๐ŸŽ‰Fun examples

โœˆ๏ธPilots use simulators too

Pilots practise for many hours in flight simulators before they fly a real plane. You test in the simulator before the real board.

๐Ÿ›Everyone makes bugs

Even expert programmers see red errors every day. The skill is not โ€œno mistakesโ€ โ€” it is reading the message and fixing it calmly.

๐Ÿค–Tinku talks

Tinku, the AI teacher in TinkerPy Code, explains your program out loud while the line he is talking about lights up โ€” and you can pick his voice.

๐ŸŒWhere itโ€™s used

๐Ÿ› ๏ธProject ideas

Fix-the-bug challenge

Type the hurried button lamp exactly as shown, mistakes and all. Press Compile and read every yellow and red note. Fix the last error, compile again and test it in the simulator. Then hide three new bugs for a friend to find.

๐Ÿงฐ You need: TinkerPy Code, a friend
Simulate before you upload

Build the button lamp in Circuit Connections (push button on i1, LED on o1). Test it in the Simulator, then in AI Simulation on ๐Ÿ‘ฃ Step. Only when it works, upload it to a real board over WiFi.

๐Ÿงฐ You need: TinkerPy Code, a TinkerPy board, button and LED modules

โญPoints to remember

  1. An IDE is one app with all the coding tools; TinkerPy Code is yours.
  2. The Code Library on the left has every function with examples.
  3. Circuit Connections writes the setup lines for the parts you pick.
  4. Always press Compile first.
  5. Yellow AUTO_CORRECT notes show slips that Compile fixed for you.
  6. Red ERROR notes show real mistakes, with the line number.
  7. Pick one buttons and SUGGESTIONS help you fix an error.
  8. Simulator and Upload open only after a good Compile.
  9. In the Simulator press Run, then press or HOLD the input buttons.
  10. AI Simulation makes the running line glow, step by step.
  11. Upload over WiFi needs the Device ID and the 4-digit board password.
  12. Bluetooth upload needs a TinkerPy Mega close by.
  13. โ€œCode uploaded!โ€ means the program is on the board.
  14. Tinku explains your code; .. opens the Magic Code Creator.
๐Ÿคฏ
Did you know?

The first compiler was built in the early 1950s by Grace Hopper. Before compilers, programs were written very close to machine code โ€” long lists of numbers and short codes!

โ“Mini quiz

๐Ÿ”‘
Log in to try the mini quiz

5 quick questions to check yourself โ€” free with your TinkerPy account.

Log in