Top Banner
© 2018 SAM Labs Binary Patterns
21

Binary Patterns - Smarttech

Apr 29, 2023

Download

Documents

Khang Minh
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Binary Patterns - Smarttech

© 2018 SAM Labs

Binary Patterns

Page 2: Binary Patterns - Smarttech

© 2018 SAM Labs

What’s the color?

Can you find the color from the hex color code?

Page 3: Binary Patterns - Smarttech

How is hex used to represent color?

Mini-lesson

Page 4: Binary Patterns - Smarttech

Mini-lesson

Using the website

https://www.w3schools.com/

colors/colors_picker.asp can

you find the color that this

hex code generates?

Page 5: Binary Patterns - Smarttech

Mini-lesson

Page 6: Binary Patterns - Smarttech

© 2018 SAM Labs

Keywords

Page 7: Binary Patterns - Smarttech

Let’s Discuss

1. What color is #ff0000?

A. Green

B. Blue

C. Red

2. In your workbook or with a partner, record, discuss, or share why hex was created.

Page 8: Binary Patterns - Smarttech

Step 1.

Drag on a Program Start block from the ‘General’ tab.

Step 2.

Create a Variable called ‘userinput’.

Step 3.

Check the variable is created in the ‘Variable’ tab.

Worked Example

Page 9: Binary Patterns - Smarttech

Step 4.

Drag on from within the ‘Variable’ tab a ‘set variable to’ block

Step 5.

Drag on from the ‘General’ tab the block starting with the wording ‘prompt’

Step 6.

In the light blue block, set the question to ‘What is your name?’.

Worked Example

Page 10: Binary Patterns - Smarttech

Step 7. From the ‘General’ tab, drag on a Print block. Connect under the ‘userinput’ block within the Program Start block.

Step 8.

From the ‘Variable’ tab, select the ‘userinput’ block. Replace the light blue text block with it.

Step 9.

Test your system by pressing ‘RUN’.

Worked Example

Page 11: Binary Patterns - Smarttech

Challenge 1

Step 1.

● Remove the ‘Print’ block. ● Edit the text to ‘What is the hex code?’

Step 2.

Remove the block from the ‘Program start’ block.

Step 3.

From the Loop tab, drag on a ‘Repeat forever’ block and connect to ‘Program start’ block.

Page 12: Binary Patterns - Smarttech

Challenge 1

Step 4.

Connect the ‘set user input’ block to the ‘Repeat forever’ block.

Step 5.

Turn on and ‘Connect’ the RGB LED by clicking ‘Add device’ and select the RGB LED block. Press and hold the power button on the block and select ‘connect’ and ‘PAIR’ on the Devices section of SAM Blockly.

Step 6.

From the RGB Light actions tab, drag on a ‘set RGB Light LED to’ block and connect the ‘set userinput’ block.

Page 13: Binary Patterns - Smarttech

Challenge 1

Step 7.

From the Variable tab, drag and replace the color red with the ‘userinput’ variable.

Step 8.

Test your system and add the hex code #ff0000.

Page 14: Binary Patterns - Smarttech

Checks for Understanding

1. How many variables are there within the system?

A. 1

B. 2

C. 3

2. What is the definition of a variable?

A. A fixed value

B. A value that can be changed

C. A value range

Page 15: Binary Patterns - Smarttech

Challenge 1 - Debug it!

Step 1.

From within the ‘General’ tab, drag on a ‘Wait 2 seconds’ block. Connect under the ‘set RGB Light’ block.

Step 2.

From the RGB Light Actions tab, drag on a ‘Turn RGB Light LED off’ block. Connect it underneath the ‘Wait 2 seconds’ block.

Page 16: Binary Patterns - Smarttech

Challenge 2

Step 1.

Use the test table in your student workbook to efficiently test your program.

Step 2.

Complete the first test ‘remove the hash tag’.

Step 3.

Complete the second test a hex code larger than the range ‘GGHHGG’.

Page 17: Binary Patterns - Smarttech

Challenge 2

Step 4.

Complete the test table on the next pagefor the color codes and compare your results to website color picker.

Step 5.

Add new Hex codes to the test table and test them.

Page 18: Binary Patterns - Smarttech

Challenge 2Complete the test table for the color codes and compare your results to website color picker.

Add new Hex codes to the test table and test them.

Hex Code Expected outcome Actual outcome

#ff0000

#GGHHGG

#00ff00

#0000ff

#ffff00

#ffc0cb

#800080

#00ccff

Page 19: Binary Patterns - Smarttech
Page 20: Binary Patterns - Smarttech

Checks for Understanding

1. What is the purpose of the ‘Repeat Forever’ block?

A. To repeat the actions once

B. To repeat the actions for a set number of times

C. To continuously repeat the actions

2. What is a loop?

A. Sequence of instructions

B. Sequence of instructions repeated until a certain

condition is reached

C. Set of step by step instructions

Page 21: Binary Patterns - Smarttech

© 2018 SAM Labs

Exit ticket

✓ Today I learned…