1 of 50

Programming Movement

SensorBot

Confidential and proprietary property of TinkRworks, Inc.

Confidential and proprietary property of TinkRworks, Inc.

2 of 50

  • Wire Motors

1

Confidential and proprietary property of TinkRworks, Inc.

3 of 50

Let's Wire our Motors

  • The motors plug in to the 4 (black) sockets at the front of the PCB.

  • Plug the black wire from one motor into the inside socket.

  • The red motor connects to the outside socket.

  • Repeat for both motors.
  • NOTICE: Red wires ore on outside ports

2

Confidential and proprietary property of TinkRworks, Inc.

4 of 50

Video

3

Confidential and proprietary property of TinkRworks, Inc.

5 of 50

Check your work

  • Make sure the black wires of your motors are on the inside ports.

  • We might have to change this when we start programming.

4

Confidential and proprietary property of TinkRworks, Inc.

6 of 50

  • Attach Bluetooth Chip

5

Confidential and proprietary property of TinkRworks, Inc.

7 of 50

Connect Bluetooth Chip

  • Identify the black sockets near the label that says “TinkR 123.”

  • Insert the Bluetooth chip with the label on the chip facing the label on the PCB.

6

Confidential and proprietary property of TinkRworks, Inc.

8 of 50

Video

7

Confidential and proprietary property of TinkRworks, Inc.

9 of 50

  • TinkRcode

8

Confidential and proprietary property of TinkRworks, Inc.

10 of 50

How do we program our bot?

9

TinkRcode

Bluetooth

Confidential and proprietary property of TinkRworks, Inc.

11 of 50

TinkRcode

  • TinkRcode is the block programming software that TinkRworks uses to program the microcontrollers.

  • To start you need to log in.

10

Confidential and proprietary property of TinkRworks, Inc.

12 of 50

It’s Time to Code!

  • Open Google Chrome (web browser)

  • Navigate to www.tinkrcode.com

  • Click “Have a Code?

11

Confidential and proprietary property of TinkRworks, LLC

13 of 50

Project Sticker

  • Find your project code sticker on the Bluetooth chip

  • You will see a set of 5 shapes and 5 numbers.

12

Confidential and proprietary property of TinkRworks, LLC

14 of 50

Project Code – from your BLUETOOTH Chip

  • You can enter the Shapes or Numbers by selecting the circle next to the words.
    • If you make a mistake, click “Clear

  • Click Next

13

Confidential and proprietary property of TinkRworks, LLC

15 of 50

Class Code

  • Enter your class code of either Fruit or Numbers.
    • If you make a mistake, click “Clear

  • Click Submit

14

Confidential and proprietary property of TinkRworks, LLC

16 of 50

Make a New Program

Select “+ New Program

15

Confidential and proprietary property of TinkRworks, LLC

17 of 50

Program Name

  • Name your program.

  • Click OK

16

Confidential and proprietary property of TinkRworks, LLC

18 of 50

Open Your Program

Open your program.

17

Confidential and proprietary property of TinkRworks, LLC

19 of 50

TinkRcode Anatomy

Workspace

Drawers

Trashcan

Zoom

Undo/Redo

Center

Confidential and proprietary property of TinkRworks, LLC

20 of 50

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

21 of 50

Connect to Bluetooth

20

  • 1. Click Connect.

  • 2. Choose the number that is on your Project Sticker and click Pair.

  • 3. Green means connected!

Confidential and proprietary property of TinkRworks, LLC

22 of 50

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

23 of 50

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.

24 of 50

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.

25 of 50

Programming motors

24

Motor A = Right motor

Motor B = Left motor

Confidential and proprietary property of TinkRworks, Inc.

26 of 50

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:

0255

(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.

27 of 50

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.

28 of 50

Connect to Bluetooth

27

  • 1. Click Connect

  • 2. Choose the number that is on your Project Sticker and click Pair.

  • 3. Green means connected!

Confidential and proprietary property of TinkRworks, Inc.

29 of 50

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.

30 of 50

Is your bot going straight?

29

Confidential and proprietary property of TinkRworks, Inc.

31 of 50

Why might our robots not go straight?

  • One motor may be turning faster than the other, because the motors aren’t exactly the same.

  • One wheel might be dragging on the frame.

  • The caster wheel may be off-center.

30

Confidential and proprietary property of TinkRworks, Inc.

32 of 50

How do you fix it?

Check your bot carefully.

  • Is there anything hitting a wheel?

  • Anything dragging on the ground?

  • Are the wheels on all the way?

  • Are the motors secure?

If those are all good, let’s look at programming solutions.

31

Confidential and proprietary property of TinkRworks, Inc.

33 of 50

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.

34 of 50

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.

35 of 50

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.

36 of 50

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.

37 of 50

  • Challenges

36

Confidential and proprietary property of TinkRworks, Inc.

38 of 50

3 Challenges

37

Confidential and proprietary property of TinkRworks, Inc.

39 of 50

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.

40 of 50

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.

41 of 50

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.

42 of 50

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.

43 of 50

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.

44 of 50

  • Solutions

43

Confidential and proprietary property of TinkRworks, Inc.

45 of 50

Challenge #1 Solution: Backward Slow

  • Motor speeds might be different to compensate for drift.

  • Students should experiment with the lowest motor speeds that will allow the bot to keep moving.

  • If the numbers are too low, the bot will make a noise, and will not move.

  • Directions should be 0.

44

Confidential and proprietary property of TinkRworks, Inc.

46 of 50

Challenge #2 Solution: Circle Left!

Left motor should go slower than right.

45

Confidential and proprietary property of TinkRworks, Inc.

47 of 50

Challenge #3 Solution: Spin Right!

Right motor should go backward; left motor should go forward.

46

Confidential and proprietary property of TinkRworks, Inc.

48 of 50

Challenge #4: Additional Movements

47

Confidential and proprietary property of TinkRworks, Inc.

49 of 50

Challenge #4: Additional Movements

Right-click to collapse the blocks.

48

Confidential and proprietary property of TinkRworks, Inc.

50 of 50

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.