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

Pins & Features of the TinkerPy Board

Every gadget starts with one question: which pin does it go on? Your TinkerPy board has input pins that listen, output pins that act, a few pins with special jobs โ€” and invisible superpowers like WiFi and Bluetooth. Letโ€™s meet them all!

๐Ÿ“–Key words

Pin

A connection point on the board. A moduleโ€™s signal wire (S / OUT / IN) goes to a pin; its VCC and GND go to the power and ground pins next to it.

Input pin (i1โ€“i4)

A pin the board reads: ON / OFF from a button, or a number 0โ€“100 from a sensor or knob (analog). The Mini has i1โ€“i2, the Mega i1โ€“i4.

Output pin (o1โ€“o8)

A pin the board controls: ON / OFF, or any level from 0 to 100 with PWM. Both boards have o1โ€“o8.

PWM

Pulse Width Modulation: switching an output on and off very fast to give โ€œhalf brightโ€ or โ€œslow speedโ€. Every output pin can do it.

I2C

A way for many modules (OLED screen, LCD, motion sensorโ€ฆ) to share two wires: SDA on o7 and SCL on o8. Each module has its own address.

๐ŸŽฌSee it work

Tour the board

Tap each pin group to see what it can do.

TinkerPy Mini or Mega?

Switch between the two boards and compare their pins and features.

๐Ÿง How it works

Input pins: the boardโ€™s ears

  • Inputs start with i. TinkerPy Mega has i1, i2, i3, i4; TinkerPy Mini has i1, i2.
  • Digital (ON / OFF): buttons, switches, motion, flame, IR sensors โ€” if button == ON:
  • Analog (0 to 100): knobs, light level, soil wetness, water level. Analog works only on input pins.
  • Special inputs like the DHT11 (temperature and humidity) and the TV-remote receiver also go on input pins. More in chapters 7 and 9.

Output pins: the boardโ€™s hands

  • Outputs start with o: o1 to o8 on both boards.
  • Every output can be ON / OFF (lamp = ON) or a level from 0 to 100 with PWM (lamp = pwm(50)) โ€” brightness, fan speed. More in chapter 8.
  • LEDs, bulbs, buzzers, servos, RGB LEDs, relays, fans and pumps go on any free output pin.
  • An output pin gives only a small signal โ€” a fan, pump or motor needs a driver or relay module in between.

Pins with special jobs

  • o7 + o8 = I2C (SDA + SCL). The OLED screen, the 16ร—2 LCD, the MPU6050 motion sensor and more all share these two pins (chapter 11).
  • Robot motors: right motor on o3 + o4, left motor on o5 + o6.
  • Ultrasonic distance sensor: TRIG i3, ECHO i4 on the Mega; TRIG i2, ECHO i1 on the Mini.
  • These jobs are switched on in Circuit Connections โ†’ Special components. When a job is off, its pins are free for normal parts.
  • The menu button belongs to the board (Code download, Download via BT, Device passwordโ€ฆ). Your program cannot read it โ€” use a push button on an input pin.

Board features: no wires needed

  • WiFi (both boards): uploads over WiFi and IoT โ€” control and watch a project over the internet.
  • Bluetooth (TinkerPy Mega): talk to your own phone app in TinkerPy App, and upload over Bluetooth.
  • Wireless and Wireless IoT (TinkerPy Mega): boards talking to other boards.
  • Counter and Clock: counting and timekeeping that run by themselves, on both boards.
  • Switch them on in Circuit Connections โ†’ Board features; the import lines are added for you. You will code them in TinkerPy Coder.

๐Ÿ’ปCode

# Add the libraries you need
import buzzer

# Give your pins easy-to-remember names
i1 = set_name("bell_button")
o1 = set_name("porch_light")
o2 = set_name("bell")

# ===== Doorbell with a light =====

# This code block executes only once
setup:
    bell_button = set_input(push_button, active_low)
    porch_light = set_output(led)
    bell = set_output(buzzer)

# This code block executes forever
loop:
    if bell_button == ON:  # when bell_button is ON
        bell = ON  # turn bell ON
        porch_light = ON  # turn porch_light ON
    else:  # otherwise
        bell = OFF  # turn bell OFF
        porch_light = OFF  # turn porch_light OFF

A doorbell that works on BOTH boards: push button on i1, LED on o1, buzzer on o2. It uses only i1 and two outputs, so the Mini and the Mega both compile it. Pin plan first, code second!

# Give your pins easy-to-remember names
i1 = set_name("button1")
i2 = set_name("button2")
i3 = set_name("button3")
i4 = set_name("button4")
o1 = set_name("light1")
o2 = set_name("light2")
o3 = set_name("light3")
o4 = set_name("light4")

# ===== Four-button panel =====

# This code block executes only once
setup:
    button1 = set_input(push_button, active_low)
    button2 = set_input(push_button, active_low)
    button3 = set_input(push_button, active_low)
    button4 = set_input(push_button, active_low)
    light1 = set_output(led)
    light2 = set_output(led)
    light3 = set_output(led)
    light4 = set_output(led)

# This code block executes forever
loop:
    if button1 == ON:  # when button1 is ON
        light1 = ON  # turn light1 ON
    else:  # otherwise
        light1 = OFF  # turn light1 OFF
    if button2 == ON:  # when button2 is ON
        light2 = ON  # turn light2 ON
    else:  # otherwise
        light2 = OFF  # turn light2 OFF
    if button3 == ON:  # when button3 is ON
        light3 = ON  # turn light3 ON
    else:  # otherwise
        light3 = OFF  # turn light3 OFF
    if button4 == ON:  # when button4 is ON
        light4 = ON  # turn light4 ON
    else:  # otherwise
        light4 = OFF  # turn light4 OFF

TinkerPy Mega only: four buttons on i1โ€“i4, each with its own LED on o1โ€“o4. The Mega has four input pins. With no robot motors switched on, o3 and o4 are free for normal LEDs.

Text
Device: TinkerPy Mini โ†’ Compile

6 errors โ€” line 4: 'i3' isn't available on TinkerPy Mini (TinkerPy Mini only has i1โ€“i2). Switch the device, or use a different pin.

The same four-button program checked for a TinkerPy Mini. Compile tells you straight away that the Mini has only i1 and i2. Fix it by switching the device back to Mega, or by planning a project that needs only two inputs.

# Add the libraries you need
import ultrasonic
import motor

# ===== Robot that stops at walls =====

# This code block executes only once
setup:
    i3 = set_input(ultrasonic_trig)  # cannot be changed
    i4 = set_input(ultrasonic_echo)  # cannot be changed
    o3 = set_output(right_motor_P)
    o4 = set_output(right_motor_N)
    o5 = set_output(left_motor_P)
    o6 = set_output(left_motor_N)

# This code block executes forever
loop:
    distance_cm = distance()  # how far it is, in cm
    if distance_cm > 0 and distance_cm < 20:  # a wall closer than 20 cm?
        robot_control("S", 0, "S", 0)  # stop both wheels
    else:  # otherwise
        robot_control("F", 60, "F", 60)  # both wheels forward at 60%
    wait(50)  # pause here for 50 milliseconds before continuing

TinkerPy Mega: a robot that stops at walls. Switching on Ultrasonic and both motors in Special components wrote the fixed-pin lines: i3 and i4 for the ultrasonic sensor, o3โ€“o6 for the motors. On a Mini the ultrasonic lines use i2 and i1 instead. You will code robots in TinkerPy Coder, chapters 3 and 4.

Open TinkerPy Code

๐ŸŽ‰Fun examples

๐Ÿง A chip is the brain

The little square chip on your board holds the processor, memory and the WiFi radio โ€” a complete tiny computer.

๐ŸšŒI2C is like a school bus

One bus (two wires) picks up many children (modules). Each child has a different house number โ€” the I2C address.

๐ŸBatting order

A cricket captain plans who bats where. A good coder plans which part goes on which pin before writing code.

๐ŸŒWhere itโ€™s used

๐Ÿ› ๏ธProject ideas

Draw and label your board

Draw your TinkerPy board on chart paper. Label every input (i1โ€“i4) and output (o1โ€“o8) and colour the special jobs: o7/o8 I2C, o3โ€“o6 motors, ultrasonic pins. Add a WiFi and Bluetooth sticker for the board features.

๐Ÿงฐ You need: chart paper, sketch pens, your board or a photo of it
Pin-planning sheet for a project

Choose a gadget (a smart doorbell, a night lamp, a quiz buzzer). Make a table: part, input or output, digital or analog, pin. Check it fits a Mini โ€” if not, mark it Mega. Then set it up in Circuit Connections and compile.

๐Ÿงฐ You need: notebook, TinkerPy Code

โญPoints to remember

  1. Input pins start with i; output pins start with o.
  2. TinkerPy Mega has inputs i1โ€“i4; TinkerPy Mini has i1โ€“i2.
  3. Both boards have outputs o1โ€“o8.
  4. Analog (0โ€“100) readings work only on input pins.
  5. Every output can do ON / OFF and PWM from 0 to 100.
  6. o7 is SDA and o8 is SCL โ€” the shared I2C pins.
  7. Robot motors: right o3 + o4, left o5 + o6.
  8. Ultrasonic: Mega TRIG i3 / ECHO i4; Mini TRIG i2 / ECHO i1.
  9. A special jobโ€™s pins are free when the job is switched off.
  10. Mini = ESP8266-12E chip; Mega = ESP32-C3 chip.
  11. Both boards have WiFi; only the Mega has Bluetooth.
  12. Board features (Bluetooth, IoT, Wireless, Counter, Clock) need no wires.
  13. Programs cannot read the boardโ€™s menu button.
  14. Pick Mega or Mini in TinkerPy Code so Compile checks the right pins.
๐Ÿคฏ
Did you know?

The same kind of tiny WiFi chip family that runs your TinkerPy board is used in many smart plugs, smart bulbs and other home gadgets around the world.

โ“Mini quiz

๐Ÿ”‘
Log in to try the mini quiz

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

Log in