1 of 45

Inputs & Outputs

2 of 45

Index

3 of 45

Input/Output

TokyMaker is capable of doing two things: receiving data from inputs and sending data to outputs.

The left side, marked in blue arrows, is for inputs. The right side, marked in red arrows, are for outputs.

4 of 45

Input/Output

Take a look at the blue arrows on the input side of the TokyMaker, what do you see?

  • “+” pin (Positive, power, plus, VCC)
  • “−” pin (Negative, ground, minus, GND)
  • A number pin (this tells you which input you are using, a TokyMaker has 5 inputs and 5 outputs)

5 of 45

Input/Output

Data

The number label on the TokyMaker inputs is for the data pin. Input sensors send numbers to the TokyMaker via the data pin.

Output sensors receive data from the TokyMaker via the data pin.

6 of 45

  • Input Practice
  • Output Practice

Input Practice

The left side of the TokyMaker has 5 input ports, marked with blue arrows.

The input ports receive signals from sensors.

7 of 45

Input Practice

When we deal with inputs, we are concerned with positive (+), negative (-), and data.

Positives can only connect to positives.

Negatives can only connect to negatives.

Data in from TokyMaker can only connect to Data out of sensors.

Vcc pins are positive.

GND pins are negative.

Dout, or OUT means data out.

Presents:

8 of 45

Input Practice

Reading from Potentiometer

Plug a potentiometer into Input 1

9 of 45

Input Practice

Open the “Hello” code on your webpage.

We are going to improve upon this program.

10 of 45

Output Practice

Display message

In the “Hello!” program, we can show a message. We can also show a message and a value on the display.

You can find the code block that prints a message and a number under the pink green “Text” tab. Select and place it inside Screen: print.

11 of 45

Input Practice

Read from Input

We need to read from Input1, where the sensor is plugged in. Find the “read IN1” from the yellow Input block, and drag it to replace the number.

12 of 45

Input Practice

Upload to TokyMaker, play with the potentiometer, and observe the readings from the display. Save your code.

13 of 45

Input Practice

Reading from Light Sensor

Plug a light sensor into Input 1.

Use the same code and observe.

14 of 45

Input Practice

Ultrasonic Distance Sensor

The sensor sends a pulse and receives its echo.

It determines the distance to a target by measuring time lapses between the sending and the receiving of the pulse.

15 of 45

Input Practice

The ultrasonic distance sensor plug-in is at the top, middle part of the TokyMaker.

16 of 45

Input Practice

Reading from Distance Sensor

  • Plug the distance sensor from the top.
  • Assemble code blocks to make the display show input data from the sensor. Find the read distance block under input tab.

  • Upload to the TokyMaker.

  • What is the maximum and the minimum reading?

17 of 45

  • Input Practice
  • Output Practice

Output Practice

The right side of the TokyMaker has 5 output ports, marked with red arrows.

The output ports send signals out, and output actuators receives signals.

18 of 45

Output Practice

When we deal with outputs, we are concerned with positive (+), negative (-), and data.

Positives can only connect to positives.

Negatives can only connect to negatives.

Data out from TokyMaker can only connect to Data in of output actuators.

Vcc pins are positive.

GND pins are negative.

The number of TokyMaker outputs means data out.

Din, or IN of actuators means data in.

19 of 45

Revision

Blink!

Blink the onHead LED of the TokyMaker by using the code you saved yesterday. Upload program to TokyMaker. Upload to TokyMaker.

20 of 45

Output Practice

Connect the LED stick

The LED stick has 3 pins: GND, VCC, IN.

VCC goes to “+”, GND goes to “—”, and IN goes to 1.

Plug the LED stick into Output 1 of TokyMaker.

21 of 45

Output Practice

Blink on LED stick

To set the LED on Output 1, click for the drop down menu, and select OUT1.

Assemble blocks to make the first pixel on the LED blink.

Upload to the TokyMaker.

22 of 45

Output Practice

Blink on LED stick

We are only blinking the first LED along the stick. How can we control other LED sticks?

We can do so by changing the address on the set LED block.

23 of 45

Output Practice

Blink on LED stick

Change the address in the set LED block, and upload to TokyMaker.

24 of 45

Blink on LED stick

Now we know how to turn on the first / second / third LED, how do we turn on all of them?

25 of 45

Output Practice

Blink on LED stick

Turn on all of the pixels by addressing all of them in your code.

Save your code.

That is a lot of lines! Can we make it shorter?

26 of 45

Output Practice

Repeat and Counter

Counter indicates how many times the loop has repeated.

1st loop……….…………………counter = 1

2nd loop…………………………counter = 2

….

100th loop..……………….counter = 100

27 of 45

Output Practice

Repeat and Counter

We can use the TokyMaker display to show us the value of counter during each repetition.

The green counter block is under the green control tab. Upload your code and save. What do you see on your TokyMaker?

28 of 45

Output Practice

Blink LED stick

Going back to the blink LED program, and insert counter.

This code blinks all the pixels on the LED stick at once.

Upload and save your code.

29 of 45

Output Practice

Speaker

Sound is generated by vibrations and waves.

In order to translate an electrical signal into an audible sound, speakers contain an electromagnet that is placed in front of a permanent magnet.

As pulses of electricity pass through the coil of the electromagnet, its magnetic field is rapidly changed.

30 of 45

Output Practice

Speaker

Speaker unit comes with a 3-pin wire. One end of the wire snaps into the speaker.

The other end of the wire is attached to pins, and then plugged into OUT1 of the TokyMaker.

31 of 45

Output Practice

Programming sound

There are two ways of making sound. The first is assigning a frequency.

The second is assigning an octave and a note. Speaker is an output device, and you can find the corresponding code blocks under the Output tab.

You can set the volume with the potentiometer mounted on the speaker.

Make interesting sound, and save your code.

32 of 45

Speaker

Sound is generated by vibrations and waves. In order to translate an electrical signal into an audible sound, speakers contain an electromagnet that is placed in front of a permanent magnet. As pulses of electricity pass through the coil of the electromagnet, its magnetic field is rapidly changed.

OUT1

Wire

Black

+

Red

1

White

EN

CN

33 of 45

Speaker

Speaker unit comes with a 3-pin wire. One end of the wire snaps into the speaker. The other end of the wire is attached to pins, and then plugged into OUT1 of the TokyMaker.

OUT1

Wire

Black

+

Red

1

White

EN

CN

34 of 45

Speaker

Please check the color of the wires.

OUT1

Wire

Black

+

Red

1

White

EN

CN

35 of 45

Speaker

You can set the volume with the potentiometer mounted on the speaker.

EN

CN

36 of 45

Speaker

There are two ways of making sound. The first is assigning a frequency. The second is assigning an octave and a note.

Speaker is an output device, and you can find the corresponding code blocks under the Output tab.

Challenge: Make 3 interesting sound, play with wait length, and save your code separately!

EN

CN

37 of 45

Speaker

Use touchpad 1, 2, and 3 to trigger three different sounds!

Refer to the programming structure example to set up the if…do logic. Apply your own music!

EN

CN

38 of 45

Project Theremin

We are going to do this project with a speaker and with a light sensor.

¡Ánimo!

EN

CN

39 of 45

Congratulations!

You know how to program music!

40 of 45

ServosServo is a small output device that has an output shaft.

This shaft can be positioned to specific angular positions (180° servos) or specific turning speed by a signal (360° servos).

Programming

41 of 45

Servos are so useful!

People have build a variety of robots using simple servos.

Programming

42 of 45

Servo Line

Pinout

TokyMaker

Brown

Red

+

+

Orange

Din

1

Attach a servo horn to the shaft of a 360° servo

Attach a 3 pin header, and connect the servo to OUT1.

Programming

43 of 45

You can control the servo with the “Set servo” block under the red Output tab.

The range of the servo is 0-180.

  • Set servo to 0.
  • Set servo to 45.
  • Set servo to 90.
  • Set servo to 135.
  • Set servo to 180.

What is your observation?

Programming

44 of 45

360° Servo

This type of servo can rotate continuously.

Set servo to 0 clockwise(fast)

Set servo to 45 clockwise(slow)

Set servo to 90 stop

Set servo to 135 anticlockwise(slow)

Set servo to 180 anticlockwise(fast)

Programming

45 of 45

Loops?

Next Lesson