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

All Digital & Analog Output Modules

Inputs let your board feel โ€” outputs let it act! Light up LEDs, spin fans, pump water, click relays, open locks, ring bells, turn servos and paint rainbows. Meet every output module in Circuit Connections and what each one does with ON, OFF and PWM.

๐Ÿ“–Key words

Output module

A part on an output pin (o1โ€“o8) that the board switches: a light, motor, relay, buzzerโ€ฆ Picked on the pin in Circuit Connections.

Relay

A switch worked by an electromagnet. A small signal from the board clicks it ON or OFF to control a separate circuit.

Servo

A motor that turns to an exact angle from 0ยฐ to 180ยฐ and holds it. It gets a start angle in Circuit Connections.

Active / passive buzzer

An active buzzer makes one beep sound when ON. A passive buzzer can play tunes with buzzer_play().

RGB LED

One LED with red, green and blue inside โ€” mixed, they make any colour. Comes as a board with 1, 2 or 3 LEDs or as a strip.

๐ŸŽฌSee it work

ON, OFF and PWM

Pick an output and see what it does with ON, OFF and pwm().

Output matching game

Sort each output: ON/OFF only, ON/OFF plus PWM levels, or its own functions.

๐Ÿง How it works

LEDs, bulbs and lasers

  • LED ๐Ÿ”ด โ€” ON, OFF or any brightness with pwm(). The most used output of all.
  • Bulb ๐Ÿ’ก โ€” a lamp; also dims with pwm(). In class use only low-voltage bulbs.
  • Laser ๐ŸŽฏ โ€” a thin, bright beam: ON / OFF only. Never point it at anyoneโ€™s eyes.
  • All outputs go on any output pin o1โ€“o8 โ€” on both the Mini and the Mega. Circuit Connections names them led_1, bulb_1, laser_1โ€ฆ and you can rename them.

Relays, motors, fans, pumps and locks

  • Relay ๐Ÿ”Œ โ€” ON / OFF only. It switches a separate circuit; anything on 230 V mains must be wired by an adult electrician, never by students.
  • DC motor โš™๏ธ, Fan ๐ŸŒ€ and Water pump ๐Ÿšฟ โ€” ON, OFF or a speed with pwm(). They spin one way; a robotโ€™s two-way wheel motors are special (chapter 12).
  • Vibration motor ๐Ÿ“ณ โ€” the buzz inside a phone; pwm() makes it stronger or softer.
  • Door lock ๐Ÿ”’ โ€” ON / OFF only, e.g. ON = unlock for 3 seconds.
  • Motors, pumps and locks need more power than a pin can give, so their modules have a driver or relay on board.

Buzzers, servos and RGB LEDs

  • Buzzer ๐Ÿ”” โ€” bell = ON beeps. Choose Beep only (active) or Tunes (passive) in Circuit Connections; buzzer_play(bell, "door_bell") plays a tone, and songs need a passive buzzer.
  • Servo ๐Ÿฆพ โ€” pick a start angle (0โ€“180ยฐ) in Circuit Connections; then servo_write_angle(gate, 90) turns it.
  • RGB LED ๐ŸŒˆ โ€” choose how many LEDs (1, 2 or 3 on a board, or a strip of up to 60); then rgb_color(signal, all, "green").
  • These three add their own import line (buzzer, servo, rgb_โ€ฆ) when you pick them.
  • Deep coding: buzzer tunes and RGB effects in TinkerPy Coder chapter 5, servos in TinkerPy Coder chapter 4, ON/OFF/PWM tricks in TinkerPy Coder chapter 2.

๐Ÿ’ปCode

Text
Output module     ON / OFF   pwm(0-100)      Setup extra          Import
----------------  ---------  --------------  -------------------  -----------
LED               yes        brightness      -                    -
Bulb              yes        brightness      -                    -
Laser             yes        no              -                    -
Relay             yes        no              -                    -
DC motor          yes        speed           -                    -
Fan               yes        speed           -                    -
Water pump        yes        speed           -                    -
Door lock         yes        no              -                    -
Vibration motor   yes        strength        -                    -
Buzzer            beep       no              active / passive     buzzer
Servo             no         no              start angle 0-180    servo
RGB LED           no         no              how many LEDs        rgb_...

Every output module goes on any output pin o1-o8 (Mini and Mega).

Every output module in Circuit Connections: what ON / OFF and pwm() do, what extra you choose in Circuit Connections, and which import line it adds. Robot motors and GSM (send) are special โ€” see chapter 12.

# Give your pins easy-to-remember names
i1 = set_name("open_button")
o1 = set_name("door_lock")
o2 = set_name("green_light")

# ===== Smart door =====

# This code block executes only once
setup:
    open_button = set_input(push_button, active_low)
    door_lock = set_output(lock)
    green_light = set_output(led)

# This code block executes forever
loop:
    if open_button == ON:  # when open_button is ON
        door_lock = ON  # unlock
        green_light = ON  # turn green_light ON
        wait(3000)  # pause here for 3000 milliseconds before continuing
        door_lock = OFF  # lock again
        green_light = OFF  # turn green_light OFF

A smart door: press the button and the door lock opens (ON) with a green light for 3 seconds, then locks again. A lock only needs ON and OFF.

# Add the libraries you need
import servo
import buzzer

# Give your pins easy-to-remember names
i1 = set_name("button")
o2 = set_name("gate")
o3 = set_name("bell")

# ===== Gate and bell =====

# This code block executes only once
setup:
    button = set_input(push_button, active_low)
    gate = set_output(servo, 0)
    bell = set_output(buzzer, passive)

# This code block executes forever
loop:
    if button == ON:  # when button is ON
        buzzer_play(bell, "door_bell")  # play the "door_bell" tone on the buzzer (bell) โ€” the next line waits until it ends
        servo_write_angle(gate, 90)  # open the gate
        wait(3000)  # pause here for 3000 milliseconds before continuing
        servo_write_angle(gate, 0)  # close it again

Gate and bell: a servo named gate (start angle 0ยฐ) and a passive buzzer named bell. One press plays the door bell tone, opens the gate to 90ยฐ, waits 3 seconds and closes it. Picking Servo and Buzzer added import servo and import buzzer for you.

# Add the libraries you need
import rgb_single

# Give your pins easy-to-remember names
o1 = set_name("signal")

# ===== Traffic colours =====

# This code block executes only once
setup:
    signal = set_output(rgb_led, 1)

# This code block executes forever
loop:
    rgb_color(signal, all, "green")  # make all LEDs on signal green
    wait(3000)  # pause here for 3000 milliseconds before continuing
    rgb_color(signal, all, "yellow")  # make all LEDs on signal yellow
    wait(1000)  # pause here for 1000 milliseconds before continuing
    rgb_color(signal, all, "red")  # make all LEDs on signal red
    wait(3000)  # pause here for 3000 milliseconds before continuing

A traffic signal with a single RGB LED board on o1: green, yellow, red. Picking RGB LED with 1 LED added import rgb_single for you.

Open TinkerPy Code

๐ŸŽ‰Fun examples

๐Ÿ“ณSilent phone

When your phone is on silent it still buzzes in your pocket โ€” that is a tiny vibration motor with an off-centre weight spinning fast.

๐ŸŽ‰Diwali lights

Some festival light strings that chase and twinkle are RGB LED strips, where every LED can show its own colour.

๐Ÿš—Car-park barrier

The barrier arm at a car park or toll gate swings up and down to an exact position โ€” your servo gate is a small model of that idea.

๐ŸŒWhere itโ€™s used

๐Ÿ› ๏ธProject ideas

Smart room plan

Plan a smart room on paper: list every output (light, fan, lock, buzzer, RGB mood light), its pin, its name and whether it needs ON/OFF, PWM or its own functions. Then set it all up in Circuit Connections and test each one in the Simulator.

๐Ÿงฐ You need: notebook, TinkerPy board or Simulator
Output matching game

Make 12 cards: 6 with output names (relay, servo, fanโ€ฆ) and 6 with jobs (open a gate to 90ยฐ, dim a lightโ€ฆ). Play memory with a friend: a pair counts only if you can say the right TinkerPy line.

๐Ÿงฐ You need: card paper, pens

โญPoints to remember

  1. Every output module goes on an output pin o1โ€“o8.
  2. LED, bulb, fan, pump, DC motor, vibration: ON, OFF or pwm().
  3. Relay, door lock and laser: ON / OFF only.
  4. A relay switches a separate circuit โ€” mains is for adults only.
  5. Never point a laser at anyoneโ€™s eyes.
  6. Motors and pumps need a driver module, not just a pin.
  7. Buzzer: active = beep only, passive = tunes.
  8. buzzer_play(bell, "door_bell") plays a tone.
  9. A servo turns to 0โ€“180ยฐ and has a start angle.
  10. servo_write_angle(gate, 90) turns the servo.
  11. RGB LED: 1, 2 or 3 LEDs on a board, or a strip up to 60.
  12. rgb_color(name, all, "green") lights it in a colour.
  13. Servo, buzzer and RGB add their own import line.
๐Ÿคฏ
Did you know?

A relay lets a small signal from a board pin control a much bigger circuit โ€” the two circuits never even touch, because an electromagnet does the switching inside.

โ“Mini quiz

๐Ÿ”‘
Log in to try the mini quiz

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

Log in