Inputs & Outputs
Index
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.
Input/Output
Take a look at the blue arrows on the input side of the TokyMaker, what do you see?
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.
Input Practice
The left side of the TokyMaker has 5 input ports, marked with blue arrows.
The input ports receive signals from sensors.
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:
Input Practice
Reading from Potentiometer
Plug a potentiometer into Input 1。
Input Practice
Open the “Hello” code on your webpage.
We are going to improve upon this program.
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.
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.
Input Practice
Upload to TokyMaker, play with the potentiometer, and observe the readings from the display. Save your code.
Input Practice
Reading from Light Sensor
Plug a light sensor into Input 1.
Use the same code and observe.
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.
Input Practice
The ultrasonic distance sensor plug-in is at the top, middle part of the TokyMaker.
Input Practice
Reading from Distance Sensor
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.
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.
Revision
Blink!
Blink the onHead LED of the TokyMaker by using the code you saved yesterday. Upload program to TokyMaker. Upload to TokyMaker.
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.
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.
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.
Output Practice
Blink on LED stick
Change the address in the set LED block, and upload to TokyMaker.
Blink on LED stick
Now we know how to turn on the first / second / third LED, how do we turn on all of them?
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?
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
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?
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.
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.
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.
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.
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 |
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 |
Speaker
Please check the color of the wires.
OUT1 | Wire |
– | Black |
+ | Red |
1 | White |
EN | CN |
Speaker
You can set the volume with the potentiometer mounted on the speaker.
EN | CN |
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 |
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 |
Project Theremin
We are going to do this project with a speaker and with a light sensor.
¡Ánimo!
EN | CN |
Congratulations!
You know how to program music!
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
Servos are so useful!
People have build a variety of robots using simple servos.
Programming
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
You can control the servo with the “Set servo” block under the red Output tab.
。
The range of the servo is 0-180.
What is your observation?
Programming
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
Loops?
Next Lesson