Programming Movement
SensorBot
Confidential and proprietary property of TinkRworks, Inc.
Confidential and proprietary property of TinkRworks, Inc.
1
Confidential and proprietary property of TinkRworks, Inc.
Let's Wire our Motors
2
Confidential and proprietary property of TinkRworks, Inc.
Video
3
Confidential and proprietary property of TinkRworks, Inc.
Check your work
4
Confidential and proprietary property of TinkRworks, Inc.
5
Confidential and proprietary property of TinkRworks, Inc.
Connect Bluetooth Chip
6
Confidential and proprietary property of TinkRworks, Inc.
Video
7
Confidential and proprietary property of TinkRworks, Inc.
8
Confidential and proprietary property of TinkRworks, Inc.
How do we program our bot?
9
TinkRcode
Bluetooth
Confidential and proprietary property of TinkRworks, Inc.
TinkRcode
10
Confidential and proprietary property of TinkRworks, Inc.
It’s Time to Code!
11
Confidential and proprietary property of TinkRworks, LLC
Project Sticker
12
Confidential and proprietary property of TinkRworks, LLC
Project Code – from your BLUETOOTH Chip
13
Confidential and proprietary property of TinkRworks, LLC
Class Code
14
Confidential and proprietary property of TinkRworks, LLC
Make a New Program
Select “+ New Program”
15
Confidential and proprietary property of TinkRworks, LLC
Program Name
16
Confidential and proprietary property of TinkRworks, LLC
Open Your Program
Open your program.
17
Confidential and proprietary property of TinkRworks, LLC
TinkRcode Anatomy
Workspace
Drawers
Trashcan
Zoom
Undo/Redo
Center
Confidential and proprietary property of TinkRworks, LLC
Taskbar
See your programs saved in the cloud
19
Save code to your device
Open code from your device
Connect project to device via Bluetooth
Download and run code on your project
Stop the code that is running on your project
Confidential and proprietary property of TinkRworks, LLC
Connect to Bluetooth
20
Confidential and proprietary property of TinkRworks, LLC
Program
TinkRcode uses drag-and-drop coding blocks.
This is your program.
Setup: In the setup section, program blocks placed here will run only once and will be run before the Loop section.
Loop: The program blocks placed here will run over and over (in order from top to bottom).
Confidential and proprietary property of TinkRworks, LLC
TinkRcode Motor Blocks
22
Click on “Motors” to find coding blocks for steering.
Select “DC Motors Setup” and drag it out of the drawer.
Confidential and proprietary property of TinkRworks, Inc.
Motor's setup
23
Change the Speed and Direction Pin numbers for Motors A and B to match the digital pins where the motor wires connect to the Arduino board.
This block tells the Arduino which digital pins control each motor.
Confidential and proprietary property of TinkRworks, Inc.
Programming motors
24
Motor A = Right motor
Motor B = Left motor
Confidential and proprietary property of TinkRworks, Inc.
Programming motors
25
Go ahead and program both motors to go forward to make sure that all your wires are hooked up correctly.
Speed Range:
0 – 255
(Stop) (Full speed)
Note: Anything below 100 will not turn motor due to friction
Direction can be:
1 = Forward
0 = Backward.
Confidential and proprietary property of TinkRworks, Inc.
Connect to the Arduino on your robot
Look at the Bluetooth chip on your robot and note the number.
26
Confidential and proprietary property of TinkRworks, Inc.
Connect to Bluetooth
27
Confidential and proprietary property of TinkRworks, Inc.
Run your program on your robot
Click the Run button at the top of the TinkRcode window.
To stop your program, click the Stop button at the top of the TinkRcode window.
28
Confidential and proprietary property of TinkRworks, Inc.
Is your bot going straight?
29
Confidential and proprietary property of TinkRworks, Inc.
Why might our robots not go straight?
30
Confidential and proprietary property of TinkRworks, Inc.
How do you fix it?
Check your bot carefully.
If those are all good, let’s look at programming solutions.
31
Confidential and proprietary property of TinkRworks, Inc.
What is Drift?
In the ideal world, setting both motors to the same speed would make the robot go straight.
But this is the real world, and sometimes the robot drifts, or curves to one side or the other.
32
In an ideal world, these should be the same.
Confidential and proprietary property of TinkRworks, Inc.
Compensate for drift
In the real world, we get drift�and we need to calibrate to offset it.
33
To compensate for the drift, just adjust the motor speeds to something other than 255—this is calibration.
Slow down whichever motor is turning faster.
Confidential and proprietary property of TinkRworks, Inc.
Setting aside blocks of code
Once you have found speeds that make your robot go straight you should save the block by moving it to the side of your program.
The block of code is no longer part of the main program and will not run.
34
Confidential and proprietary property of TinkRworks, Inc.
Comment your code
Add a comment to the block of code indicating what it does.
Writing descriptive comments is a key component of good programming!
35
Pull this block out of the “Serial Print” drawer.
Confidential and proprietary property of TinkRworks, Inc.
36
Confidential and proprietary property of TinkRworks, Inc.
3 Challenges
37
Confidential and proprietary property of TinkRworks, Inc.
Challenge #1: Backward Slow
Challenge Name
Backward Slow
Challenge Objective
On a new Motors Speed block, experiment to find the numbers and directions that will make the robot go backwards slowly in a straight line.
Once it works, drag the block to the side and add a comment.
Challenge Notes
What should your motor directions be?
What should your two motor speeds be?
38
BACKWARD
Confidential and proprietary property of TinkRworks, Inc.
Challenge #2: Circle Left!
Challenge Name
Circle Left!
Challenge Objective
Program your bot to move in a counter-clockwise circle.
Once it works, drag the block to the side and add a comment.
Challenge Notes
What should your steering be set to?
39
Confidential and proprietary property of TinkRworks, Inc.
Challenge #3: Spin Right!
Challenge Name
Spin Right!
Challenge Objective
Program your bot to spin clockwise in place.
Once it works, drag the block to the side and add a comment.
Challenge Notes
What should your steering be set to?
40
Confidential and proprietary property of TinkRworks, Inc.
Keeping your workspace neat
Once you have a block of code working correctly, you can collapse it so that it doesn’t take up so much space.
Right-click on the DC Motors block and choose “Collapse Block.”
Your code will take up less space on the screen, leaving you more room to work.
You can undo this by right-clicking again and choosing “Expand Block.”
41
Confidential and proprietary property of TinkRworks, Inc.
Challenge #4: Additional Movements
See if you can develop each of these blocks of code:
Comment and Save your Blocks for later use
42
Confidential and proprietary property of TinkRworks, Inc.
43
Confidential and proprietary property of TinkRworks, Inc.
Challenge #1 Solution: Backward Slow
44
Confidential and proprietary property of TinkRworks, Inc.
Challenge #2 Solution: Circle Left!
Left motor should go slower than right.
45
Confidential and proprietary property of TinkRworks, Inc.
Challenge #3 Solution: Spin Right!
Right motor should go backward; left motor should go forward.
46
Confidential and proprietary property of TinkRworks, Inc.
Challenge #4: Additional Movements
47
Confidential and proprietary property of TinkRworks, Inc.
Challenge #4: Additional Movements
Right-click to collapse the blocks.
48
Confidential and proprietary property of TinkRworks, Inc.
TinkRworks, Inc.
501 W Lake Street, Suite 106
Elmhurst, IL 60126
www.TinkRworks.com
© TinkRworks, Inc. All rights reserved
Sparking CREATIVITY
Fostering INNOVATION
Sharpening PROBLEM-SOLVING skills
Confidential and proprietary property of TinkRworks, Inc.