S C R A T C H C O D I N G Coding the Ultrasonic Turtle Coding the Ultrasonic Turtle You have to turn on the LED sensor according to the distance of the ultrasonic sensor. There are three LED sensors on the ultrasonic turtle. When the tortoise is closest to the wall, the LED sensor is off. After that, as the tortoise gets further and further away from the wall, the LED will turn on one by one. First, try coding the first LED sensor.
72 CLASS 3 Coding the Ultrasonic Turtle Coding the Ultrasonic Turtle Remember when you coded the mini windmill to work according to the distance of the ultrasonic sensor? If the LED sensor of the digital port 10 is off and the digital value of the digital port 10 is higher than that of the analog value of 15 (if the value is larger) You can code it so that the LED sensor is on.
S C R A T C H C O D I N G Coding the Ultrasonic Turtle Codig the Ultrasonic Turtle Did you check that the first LED sensor turns on and off with distance? Now try coding for the second and third LED sensors. The standard for the analog value of the first LED sensor was '15'. Second, code the setting of the analog value of the third LED sensor as '20', '25'. Along with the analog value criteria, the number of digital ports will of course change.
74 CLASS 3 Coding the Ultrasonic Turtle Coding the Ultrasonic Turtle Have you tried coding for the rest of the LED sensors? Now you can combine your scripts into one. If you followed this process well then you should have a script like this! The script shown above now turns on the LED sensors one at a time as the distance from the wall increases. If the distance value is less than 15, all three LED sensors are turned off.
S C R A T C H C O D I N G “IF” syntax utilization Using ‘IF’ syntax In the past we created a script using the 'if & if' syntax. If so, now 'if; Use the syntax to create a script for the Ultrasonic Distance Meter. I can make it very simple. And think about how to code the 'or' part. Now, changing the 'if & if' syntax to the 'if' syntax will be very easy for many departments. Keep in mind that it is still important to continue practicing. Let's create a script below.
76 CLASS 3 “IF” syntax utilization Using ‘IF’ syntax If you had previously controlled the digital output with the 'if & if' statement, Take control of the digital output with two phrases. First, when the ultrasonic sensor value is low (when the recognition board is approaching), the first LED sensor should be off. Create a script The above script will turn off the LED sensor connected to the digital 10 port when the ultrasonic sensor value is less than '15'.
S C R A T C H “IF” syntax utilization Coding ‘IF’ syntax If you combine the script you made, it should look like the one below! C O D I N G K I T
78 CLASS 3 “IF” syntax utilization Utilizing the Ultrasonic Turtle An ultrasonic turtle is a model that turns on multiple LED sensors as the distance from the wall increases. It was a model in which the LED sensor was turned on cumulatively every time the distance was distant. Now, let's create a script that turns on the LED sensors sequentially, rather than turning them on cumulatively.
S C R A T C H C O D I N G “IF” syntax utilization Utilizing the Ultrasonic Now make a script that modifies the script so that the LED sensors do not turn on cumulatively, but instead turn on sequentially. Please refer to the 'DJ Box' script you learned earlier. Use the 'and' operator to make the condition better. Let's create a script in the space below.
80 CLASS 3 “IF” syntax utilization Utilize the Ultrasonic Turtle In order to turn on the LED sensor sequentially, it is necessary to distinguish the sections first. The analog reference values you currently have are '15', '20', '25'. If so, a total of four sections will be created.
S C R A T C H C O D I N G “IF” syntax utilization Utilize the Ultrasonic Turtle First, it's easy to code three sets of LED sensors on and off. Combine the three digital coding blocks as shown below and adjust the values for each section. With this combined coding block, you can adjust the value for each section. Remember that the LED sensor will turn on sequentially and complete the script.
82 CLASS 3 “IF” syntax utilization Utilizing the Ultrasonic Turtle If you combine all the scripts you have made, it should look like the one below!
S C R A T C H C O D I N G “IF” syntax utilization Utilizing the Ultrasonic Turtle By subtracting the unnecessary digital output blocks from each section, you can create shorter scripts. Try to reduce the length of the script by subtracting the unnecessary coding blocks. Please see below for reference.
84 CLASS 3 “IF” syntax utilization Utilizing the Ultrasonic Turtle Now you can use the ultrasonic turntable you just made in front of you and use the sound tap of the scratches and the ultrasonic sensor to play differently depending on the distance. Now, instead of the LED sensor, we will use the sound tab to make the sound in accordance with the distance of the ultrasonic sensor in the scratch program.
S C R A T C H C O D I N G “IF” syntax utilization Utilizing the Ultrasonic Turtle Similar to the concept of an ultrasonic LED sensor, let's make a turtle that makes a piano sound according to distance. First, click on the Sounds tab and drag the block below. Double-click the above coding block. Can you hear the sound? If you can not hear the sound, you need to connect your earphone or speakers to your computer to create an environment that can make a sound. Make sure your computer is muted.
86 “IF” syntax utilization CLASS 3 Ultrasonic Turtle ‘Do’ Now, let's create a script in earnest. Let's start by setting the standard for distance. Consider the first distance reference as the analog value '10'. Just like I had the baseline when I turned on the LED sensor in the front. Now, start coding '10', assuming that the value is incremented by '5' so that the interval is fixed. First, let's create a script to play the Do when it is smaller than the analog value '10'.
S C R A T C H C O D I N G “IF” syntax utilization Ultrasonic Turtle ‘Re’ Now let's create a script that gives the next scale. You have to run it when the analog reference value is less than '15'. In the script I created earlier, let's create a nested 'if & else' statement. Create the script below! The above script is a script that tells you to play 62 scales in one beat if the distance between the ultrasonic turtle and the wall is less than '15'.
88 CLASS 3 “IF” syntax utilization Ultrasonic Piano Playback Now you can refer to the previous script and create the rest of the script! It will be very easy from now on. Please set the scale value corresponding to each order correctly. You can continue to nest the 'if & else' syntax. Let's create a script in the space below.
S C R A T C H C O D I N G “IF” syntax utilization Ultrasonic Piano Playback Have you created a script for each kind of script? Once you have created the script, it will look like the one below. So what should I add to the last 'if & if' syntax? If the analog value is greater than '45', wait 1 second instead of playing the scale.
90 CLASS 3 “IF” syntax utilization Ultrasonic Piano playback The final script for the ultrasound piano will look like this!
S C R A T C H C O D I N G Replace the Ultrasonic Piano Instrument Replace the Ultrasonic Piano Instrument On the Sound tab, add the following block to your script! Let’s use another instrument instead of the piano in the above coding block.
92 S C R A T C H C O D I N G K I T Logic CLASS 3 Boost Line Tracer LESSON 7
S C R A T C H C O D I N G Activity Line Tracer Now you are going to make a comprehensive model using a variety of motors and sensors. Let's try to code the motion of the model by using infrared sensor, ultrasonic sensor and DC motor learned in the previous. The name of this model is the line tracer. A line tracer literally moves along a line. The line tracer you create moves along the black line.
94 Activity CLASS 3 Line Tracer Make a Line Tracer Left IR sensor Right IR sensor 1 2 ULTRASONIC SENSOR 3 4 5 6 7 8 B R W Right IR sensor Left IR sensor Line부품리스트 Tracer materials 부품리스트 부품리스트 부품리스트 부품리스트 부품리스트 부품리스트 부품리스트 Diamond H8 Diamond V8 Diamond V6 x1 x4 x2 middle connector x 2 Rubi 8 x4 Rubi 7 x6 44 Sawtooth36 Off-road4 A45 33 Sawtooth12 x4 4 wheel x 2 x5 444 3x3333 4 Rubi 4 x4 Rubi 6 x9 99 9 9999 Rubi 2 x2 9 Rubi 0 x7 9 Mini 2 x 12 A64 축 축 축 64 64 축64 64 x2 3 3
S C R A T C H C O D I N G K I T Activity 1 부품리스트 x1 부품리스트 부품리스트 4 9 12 x2 4 x4 축 64 3 9 4 3 축 64 3 12 3핀 연결잭 축 64 3 4 3핀 연결잭 3 부품리스트 부품리스트 3 12 9 부품리스트 x1 8 9 12 9 축 64 4 12 축 64 4 3 4핀 연결잭 8 축 64 3 1 9 8 3핀 연결잭 4핀 연결잭 3 3핀 연결잭 3 축 64 12 1 1 4핀 연결잭 3핀 연결잭 3 1 9 부품리스트 12 12 8 4 4 Figure 1 3 3핀 연결잭 4 12 x4 8 3핀 연결잭 4핀 연결잭 3 4 3핀 연결잭 4핀 연결잭 3 4핀 연결잭 3 1 Make two of these 1 4 축 64 4핀 연결잭 3 1 9 8 9 3핀 연결잭 3 3축 64 9 3 4핀 연결잭
96 Activity CLASS 3 부품리스트 7 8 부품리스트 x2 부품리스트 12 9 12 9 8 8 A 45 x1 12 9 4 축 64 3 3핀 연결잭 x1 3핀 연결잭 4 4핀 연결잭 x3 2 4 3 3 9 축 64 3 1 8 4핀 연결잭 1 12 3핀 연결잭 3 축 64 8 4핀 연결잭 Figure 7 1 3핀 연결잭 4핀 연결잭 3 9 Figure 8 부품리스트 Figure 3 1 10 부품리스트 bottom 부품리스트 리스트 11 부품리스트 Figure 10 9 12 Figure 2 12 8 12 A 64 9 x2 124 3핀 연결잭 3 3핀 연결잭 x2 4 8 9 축 64 3 3 8 9 3 축 64 x2 3 축 64 4핀 연결잭 4 12 1 x3 2 4핀 연결잭 1 4핀 연결잭 9 축 64 8 4 12 3핀 연결잭 3 4핀 연결잭
S C R A T C H C O D I N G Activity 부품리스트 리스트 13 14 부품리스트 부품리스트 x2 부품리스트 부품리스트 x2 x2 12 98 12 9 8 x2 12 9 트트 12 x 92 4 4 3 4 4 3 축축 6464 9 x1 축 64 3 9 축 64 1 3핀 연결잭 8 4핀 연결잭 1 연결잭 3 3핀 연결잭 3 4핀 연결잭 4 12 12 8 4 3 4 3핀 연결잭 4핀 연결잭 3 1 축 64 3 4핀 연결잭 3 3핀 4핀 Figure 연결잭 12 연결잭 1 4핀 연결잭 3 1 1 16 3핀 연결잭 38 4핀 연결잭 8 4핀 연결잭 1 3 3 3 x12 2 9 3 x4 3핀 연결잭 3핀 연결잭 3 3 축 64 4핀 연결잭 Complete 12 12 3 4핀 연결잭 1 4핀 연결잭 1 3핀 연결잭 Figure 17 3 8 4핀 연결
98 CLASS 3 Activity Coding the Line Tracer Coding the line tracer. Do you remember the line follower model you learned earlier? Now, use two infrared sensors to code the line tracer on the black line. Each infrared sensor can tell if the car is on line or not. The program will use the following logic to move the car along the line. 1. If the left infrared sensor is on the black line and the right infrared sensor is not on the black line, we will activate the right motor and turn it to the left. 2.
S C R A T C H C O D I N G Activity Coding the Line Tracer When the left infrared sensor detects the line (detects the absorption of light), the line tracer moves to the left, and when the infrared sensor on the right detects the line (detects the absorption of light), the line tracer will move to the right. If you detect a line (if there is less reflection of light in fact) you will continue to go straight.
100 CLASS 3 Activity Coding the Line Tracer Now you can code your own line tracer yourself. If the infrared sensor on the left of the two infrared sensors is white and the infrared sensor on the right is black, operate the left DC motor. If the infrared sensor on the left is black and the infrared sensor on the right is white, do. And, when the ultrasonic sensor detects the obstacle in the line tracer in progress, the operation should stop. All the movements will stop even if they leave the black line.
S C R A T C H C O D I N G Commentary Coding the Line Tracer Ultrasonic sensor Try coding when the infrared sensor on the left of the two infrared sensors is on the black servant and the infrared sensor on the right is not on the black line. If the infrared sensor is on a black subdivision, the analog value will be smaller, and if it is not over the black line, the analog value will be larger. I'll think of the threshold as '40' and try coding.
102 CLASS 3 Commentary Coding the Line Tracer Ultrasonic sensor Now you're going to try coding for an ultrasonic sensor. The line tracer must stop when it encounters obstacles along the black line, which is very simple. When the distance of the object approaches the ultrasonic sensor, you can create a script that stops the two DC motors. It will be very simple.
S C R A T C H C O D I N G Commentary Coding Line Tracer Timer Create a script that stops when the line tracer follows the black line and then goes off. It is very easy to use the timer I learned earlier. If the line tracer leaves the line, the analog value will be lower for both infrared sensors. In other words, one is that the analog value is big and one is not the analog value is small.
104 CLASS 3 Commentary Coding Line Tracer If you add a "timer initialization" block to your previously created script, it will look something like this: In this case, if the line tracer is working properly, the timer will be reset so that it will not exceed 1 second. It will not stop the motor because it does not exceed one second, right? Now combine your scripts.
S C R A T C H C O D I N G Commentary Coding Line Tracer If you combine all of the scripts created by various departments, you'll see something like this! It's a basic thing to celebrate endless repetition and execution blocks, so you can do it yourself.
106 S C R A T C H C O D I N G K I T Logic CLASS 3 Boost Tori Secret Safe LESSON 8
S C R A T C H C O D I N G Introduction Tori Secret Safe The Tori secret safe is a model that opens and closes the door of the safe only when you enter a number that matches the password specified in the scratch program. I will code the program using all four kinds of sensors (infrared sensor, button sensor, LED, sound sensor). At first, you can enter numbers from 1 to 4 using the button sensor connected to the ports 0 to 3 of the analyzer with the door open.
108 CLASS 3 Introduction Coding the Tori Secret Safe (principle) There are a lot of behaviors to express in the Tori secret safe. Since the program is not simple, we need to make sure the code is clean before doing the complicated coding. Let’s try to arrange these actions once on this page. 1. With the door open, enter the numbers from 1 to 4 as the password when the button sensor connected to the analog input ports 0 ~ 3 is accessed.
S C R A T C H C O D I N G Activity Button sensor 1 2 3 LED sensor 4 5 6 7 8 11 12 13 14 15 16 17 1 8 B B R R W W IR sensor SONG GENERATOR 금고부품리스트 금고부품리스트 금고부품리스트 Secret Safe materials 금고부품리스트 금고부품리스트 금고부품리스트 금고부품리스트 금고부품리스트 금고부품리스트 금고부품리스트 굵은 굵은돌기 2돌기셀 7돌기셀 기본셀 6돌기셀 4돌기셀 2단셀 서보셀 굵은 굵은 7돌기셀 굵은돌기 굵은돌기 2돌기셀 2돌기셀 7돌기셀 기본셀 기본셀 6돌기셀 6돌기셀 4돌기셀 4돌기셀 2단셀 2단셀 서보셀 서보셀 굵은 굵은돌기 2돌기셀 7돌기셀 6돌기셀 4돌기셀 굵은 굵은 직각셀 굵은 굵은돌기 굵은돌기 굵은돌기 직각셀 직각셀 2돌기셀 2돌기셀 7돌기셀 7돌기셀 기본셀 기본셀기본셀 6돌기셀 6돌기셀 4돌기셀 4돌기셀 2돌기셀 7돌기셀 2단
110 Activity CLASS 3 Making Secret Safe 1 2 금고부품리스트 금고부품리스트 x 40 굵은 직각셀 굵은돌기 직각셀 굵은돌기 직각셀 40 7돌기셀 6돌기셀 2 2 메인셀 128 베터리 케이스 1 1 메인셀 128 베터리 케이스 1 1 4돌기셀 6 2 22 1 1 6돌기셀 굵은 직각셀 서보모 터 서보모 터 7돌기셀 x2222 2 40 x2 금고부품리스트 금고부품리스트 6 2 기본셀 4 2 2돌기셀 4돌기셀 2돌기셀 2단셀 4 4 버튼 센서 22 서보모 터 1 7돌기셀 22 2 6돌기셀 베터리 케이스 1 1 1 메인셀 128 베터리 케이스 6 2 6 2단셀 4 4 기본셀 2단셀 4 4 2 2 2 버튼 센서 1 연결잭 8 4 LED 센서 적외선 센서 소리센서 (SONGGENERAT (LIGHT 서보셀 서보셀 LED 센서 적외선 센서
S C R A T C H C O D I N G Activity Tori secret safe variable coding We need a lot of things to make a script for the Tori secret safe. The important thing is 'variable'. Do you remember? In scratch, you can think of variables as storage. You name the variable (storage space) and put the value into that variable. In the Tori secret safe model, we have to use a total of four variables.
112 CLASS 3 Activity Tori secret safe variable coding We need a lot of things to make a script for the Tori secret safe. The important thing is 'variable'. Do you remember? In scratch, you can think of variables as storage. You name the variable (storage space) and put the value into that variable. In the Tori secret safe model, we have to use a total of four variables. If you have a lot of variables, you can improve your readability when coding by giving a proper name for the purpose of the variable.
S C R A T C H C O D I N G Activity Tori Secret Safe List coding We need to use 'list' to create the ability to store passwords for the Tori secret safe. A list is a function that allows you to save as many values as you want. The list you need is a list of 'input numbers' and a list of 'passwords'. The Tori secret safe must store the number of button sensors you press in the list for 'input number' in order and then store the pre-stored password in the list for 'password'.
114 CLASS 3 Activity Tori Secret Safe Activation Coding Once the password is set, you have to send a signal to start the full program. At this time, we use the 'broadcast' block. As we discussed earlier, ‘broadcasting’ means sending signals in scratch. If you do a broadcast, you have to get a broadcast. Tori Secret Safe Broadcasting The above picture is a script with the 'Broadcast' block added.
S C R A T C H C O D I N G Activity Tori Secret safe basic setting coding We'll create a script when we receive the broadcast, with the 'Broadcast' block we learned earlier. First, create a script when you receive the 'StartUp' broadcast. The role of 'when receiving StartUp' script is to set the initial value of the variable and to set the other operation of the LED sensor whether to open or close the door. Let's go ahead and make it! Create a script like the one above.
116 CLASS 3 Activity Tori Secret Safe LED Coding Let's take a closer look at the script for the LED sensor behavior in the 'StartUp' script we learned earlier. At the end of the 'StartUp' script, there is a big script to see how the LED sensor works. The role of this script is to keep the LED sensor on continuously when the door is open and to blink the LED sensor every 1 second if the door is closed. Make a script like the one above.
S C R A T C H C O D I N G Activity Tori Secret Safe ‘Open_door’ coding Now let's create a script when we receive the 'Open_Door' broadcast. The role of the 'Open_Door receiving' script is to open the door and play the sound sensor for 2 seconds. Let's make it Create a script like the one above. First, open the door by activating the angle of motor 8 (servomotor) by the value stored in 'Open' variable. After that, turn on Digital 11. (Turn on the sound sensor.
118 CLASS 3 Activity Tori Secret Safe ‘close_door’ Coding Use the script on the right to code the script when the door is closed. If 'Open_Door' was a broadcast when the door was opened, if it was closed, try coding it to start with 'Close_Door' broadcasting.
S C R A T C H C O D I N G Activity Tori secret safe ‘Close_door’ coding You have learned that the broadcast that opens the door in the front is 'Open_Door'. Now create a script when you receive a broadcast that closes the door. The name of this broadcast is 'Close_Door' for associativity. The role of the 'Close_Door Receiving' script is to close the door and play the sound sensor for 2 seconds. Let's go ahead and make it. reate a script like the one above.
120 CLASS 3 Activity Enter the Tori Secret Safe Number Now let's learn coding using the button sensor and the infrared sensor to enter the number. We'll add the number to the 'Code' list when we press the button sensor once. Make a script like the one above First, use the 'if' block. It is a block that executes an internal script when certain conditions are met. The condition here is the value of the analog 0 sensor <90. There are four button sensors connected to the current input analog ports 0 ~ 3.
S C R A T C H C O D I N G Activity Enter the Tori Secret Safe Number Create a script like the one above using the script you created in the previous page. There is an 'iterate through' (repeat until) block in the 'infinite loop' block that keeps repeating the script inside. 'Repeat to' (repeat until) block is a block that executes internal scripts until a certain condition is reached. As shown above, the condition of the block 'to repeat' is 'Analog 4 sensor value <90'.
122 CLASS 3 Activity Enter Tori Secret Safe Number When using the script on the right and pressing the button sensors of analogue 1 ~ 3, try to save the numbers from '2' to '4' in the 'Code' list. Code the script when it's closed.
S C R A T C H Activity Tori Secret Safe Activation Coding The script in the executable part of the Tori secret safe will look like this: C O D I N G K I T
124 CLASS 3 Activity Tori secret safe door motion coding Now let's create a script when we receive the 'doorlock check' broadcast. The role of the 'when doorlock check is received' script is to broadcast a message that the door is closed if the number entered when the door is open matches the password. If the number entered when the door is closed matches the password, the door will open. Let’s go ahead and make it! Create a script like the one above.
S C R A T C H C O D I N G Activity Tori secret safe door close comparison coding Now create a script when you receive the 'Close_Check' broadcast. The 'Close_Check Received' script's role is to compare the entered number against the password and close it if it matches, or 'Password_error' if it does not match. Let's make it once. First, when you receive the broadcast, save '1' in the 'Pointer' variable.
126 CLASS 3 Activity Tori secret safe Password Inconsistent coding Now let's create a script when we receive the 'Password_error' broadcast. The primary function of the 'Receive Password_error' script is to play the sound sensor twice at 0.2 second intervals when the entered number and password do not match. Let’s go ahead and make them. Make a script lie the one above. When you receive a broadcast, delete all the items in the 'Code' list. It deletes all the input numbers so that they are not left.
S C R A T C H Activity Tori secret safe Door open Comparison Coding Use a script on the right to code a script that compares the number and password you enter when the door opens.
128 CLASS 3 Activity Tori secret safe door open comparison coding You should have learned that the broadcast you are comparing, when you close the door, against the password is 'Close_Check'. Now, create a script that compares passwords when you open the door. The name of this broadcast is 'Open_Check' for association. The role of the 'Receive Open_Check' script is to compare the entered numbers against the passwords to see if they match, and if it does not match, open 'Password_error'.
S C R A T C H C O D I N G Activity Tori secret safe entire coding Now I have created all the scripts for the Tori secret safe. Do you understand well? If you do not understand well, please read it again and study. If you have been following so well, the entire script below will be complete! ※ The whole script can be found at http://www.robotori.
130 CLASS 3 Activity Tori Secret Safe Play Now run the coded Tori secret safe program and see if it works. If it does not work, check to see if there is anything wrong starting from the beginning of the book. Let's unlock the code and open the safe.
S C R A T C H C O D I N G Activity Tori Secret Safe Problem 1 Does your coded safe work? If so, try a little application. Your current password is '1234'. Let’s change the password now. Think carefully about what you learned earlier. Let's create the 4 digits of the desired password with numbers from 1 to 4.
132 CLASS 3 Commentary Tori Secret Safe Problem 1 commentary Did you change the password? Now you can enter 4 numbers from 1 to 4 as you have added '1234' in 'Key' list. The above script puts '2', '4', '1', '3' in positions 1,2,3,4 of 'Key' list.
S C R A T C H C O D I N G Activity Tori Secret Safe Problem 2 This time, we'll set the password to '1003'. Now we have a number from 1 to 4 and I have set and coded it. Please code how you would like to change the input number when other numbers are entered. Let's make it input when the password is set to '1003'.
134 CLASS 3 Commentary Tori Secret Safe Problem 2 commentary Change what you learned in question 1 to change the password to "1003" and change the input number from 0 to 3 instead of 1 to 4. If you change only the numbers so that the input number is 0 ~ 3 instead of 1 ~ 4, the number of the button sensor changes from 0 ~ 3, so you can press '1003' to operate the door.
S C R A T C H C O D I N G Activity Tori Secret Safe Problem 3 Now let's set the password to 6 digits. Now we'll try to code from 1 to 4 so that our password is 6 digits. When you save your password in the 'Key' list, try to code 6 entries. Let's create a six-digit password.
136 CLASS 3 Commentary Tori Secret safe problem 3 commentary Have you changed your password to 6 digits? Just add two more blocks to the script that saved the four-digit password stored in the 'Key' list and save a total of six passwords. You can enter 4 numbers from 1 to 4 as you have added 4 '1234'. We can add two more blocks of 'input ~ to ~position of Key' to make my password six digits. You can pick 2 of the numbers from 1 to 4 and add them to positions 5,6 in the 'Key' list.
S C R A T C H C O D I N G Activity Tori Secret Safe problem 4 In this case, to open the safe, the user must input the button sensor and specify the password. Then, in order to close the door, the user must press the number corresponding to the password inputted by the button sensor, the door is opened. We need to create a variable that compares the number of digits in the password and a variable that stores the user's password.
138 CLASS 3 Commentary Tori Secret Safe Problem 4 commentary Let’s try to get rid of the part where we set the password in 'Key' list in the beginning because it is a way to input the password directly. The rest of the 'Broadcast' block is the same. We are only removing the part that sets the password. When you start the program, broadcast 'StartUp' and 'Open_Door'.
S C R A T C H Commentary Tori Secret Safe Problem 4 Commentary The activated script will look like below C O D I N G K I T
140 CLASS 3 Commentary Tori Secret Safe Problem 4 Commentary Let’s make a script for when you receive ‘StartUp’ broadcast. The role of the 'When received StartUp' script is to set the initial value of the variable, and to set the behavior of the LED sensor whether the door is open or closed. Create a script like the one above. The 'keycnt' variable stores the number of digits. The 'index' variable stores the number entered in the 'Code' list into the 'Key' list.
S C R A T C H C O D I N G Commentary Tori Secret Safe Problem 4 Commentary Now let's create a script when we receive the 'Open_Door' and 'Close_Door' broadcasts. 'When you receive the Open_Door' script, it will open the door and play the sound sensor for 2 seconds. The role of the 'Close_Door Receiving' script is to close the door and play the sound sensor for 2 seconds. Shall we make it? Create a script like the one above.
142 CLASS 3 Commentary Tori Secret Safe Problem 4 commentary Now let's create a script when we receive the 'doorlock check' broadcast. The role of the 'when receive doorlock check' script is to save the entered number as a password when the door is open and close the door. When the door is opened, if the entered number matches the password, the close_door is broadcasted. When the door is closed, the entered number and password are compared. If they match, the open_door is broadcasted.
S C R A T C H C O D I N G Commentary Tori Secret Safe Problem 4 commentary Now let's create a script when we receive the 'Save_Password' broadcast. The main function of the 'Save_ PasswordReceived' script is to store the entered number as a password. Here we use the variables 'index' and 'keycnt'. Create a script like the one above. When receive the broadcast, it’ll store 1 in the 'index' variable. The 'Pointer' variable now has a cumulative number from 1 to the number entered by the user.
144 CLASS 3 Commentary Tori Secret Safe door close comparison coding Finally, let's create a script when we receive the 'Check_Password' broadcast. When you receive the 'Check_ Password' script, the role of the script compares the entered numbers against the passwords to see if they match, and if it does not match, it will broadcast 'Password_error'. Let's make it. Create a script like the one above.
S C R A T C H C O D I N G Summary Tori Secret Safe Summary How did you like making a secret safe in Tori? In addition to the four problems you have, there are some areas where you can do more applications depending on your imagination and creativity. You can now handle all four sensors (button sensor, infrared sensor, sound sensor, LED sensor) freely. Think about various coding methods based on this Tori secret safe.
146 S C R A T C H C O D I N G K I T Logic CLASS 3 Boost Dancing Robots LESSON 9
S C R A T C H C O D I N G Making a Robot Dancing Robots Let's make a robot dance. You can use the scratch program to make a variety of expressions using infrared sensors and LED sensors. There are 3 motors and 5 sensors in the dancing robot. We use two DC motors, one servo motor, one new infrared sensor and four LED sensors. As you code your dancing robot, you will learn to 'modulate'. It is possible to classify various complicated actions to make the script simpler.
148 Making a Robot CLASS 3 Dancing Robots Let’s make a dancing robot.
S C R A T C H C O D I N G Making a Robot Making a Robot 1 2 x2 x2 x2 x2 A23 x2 3 x2 x2 4 x2 A45 x1 x2 x1 A23 Four crossholes must be horizontal. 5 6 x2 x1 x2 x2 A23 x2 x1 x1 A23 x2 Four crossholes must be horizontal.
150 CLASS 3 Making a Robot Making a Robot 9 10 x1 9 8 x1 x4 9 11 12 x4 x1 x8 x1 x2 x4 13 15 14 x4 x2 x2 x2 x1 x1 12 13 16 x1 x1 x6 x1 x4
S C R A T C H C O D I N G Making a Robot Coding Dancing Robot s Coding a dancing robot. The dancing robot will illuminate the LED sensor in sequence and move the DC motor and servomotor when the infrared sensor is turned on. Infrared sensor Outputs the LED sensor through one input and is able to operate the motor. The program will work in the following order. 1.When you cover the infrared sensor by hand, the four LEDs turn on and off in sequence. 2.
152 Activity CLASS 3 Coding Dancing Robots The dancing robot needs to create a total of three scripts. First, it consists of a script for starting and stopping the program and infrared sensor recognition, a script for turning on the four LED sensors in sequence, and a script for activating the motor. The program will check whether the infrared sensor is recognized or not and move accordingly. Check the flowchart below and think of the program as repeating. The dotted line will be the individual script.
S C R A T C H C O D I N G Activity Coding Dancing Robots Before, we decided to make three dancer robots scripts. But before that, try coding as you know it. Before we learn the concept of 'modularity' we can code a dancing robot that does the same thing in one script. First, when the script is executed, set the angle of servo motor to 90. After that, when the infrared sensor is recognized, the four LED sensors turn on for 0.1 second each in turn, then the servo motor moves 180 degrees for 0.
154 CLASS 3 Commentary Dancing Robots Did you create a script? If it does not work, please refer to the script below. First, the script should start when you click on the flag icon and set the servo motor angle to 90 degrees. Put an 'infinite loop' block below it. Inside the 'Infinite Repeat' block, insert the block to turn on the LED sensor in 0.1 second increments. After turning on the LED sensors one after another, you have to operate the servomotor at 180 degrees for 0.1 second, for 4 seconds at .
S C R A T C H C O D I N G Activity Modular coding for dancing robots From now on, we will learn about modularization. You may feel that the script you learned earlier is somewhat complicated to code. Modularization of these scripts (in smaller units) makes it easier to understand when coding. First of all, let's divide the script into three and code it simply. We need a 'make broadcast' block to split the script into three. In Scratch, 'broadcast' means to send a signal.
156 CLASS 3 Activity Modular coding for dancing robots Let's divide the entire script we created earlier into three scripts. First, let's create a script that runs when the flag icon is clicked. You can substitute the 'broadcast and wait' block instead of the LED and motor. Please see below. Do you understand this script? Set the servo motor to 90 degrees at first. Then, in the 'Infinite Repeat' block, 'If the value of Analog 0 Sensor is <50', put the block as before.
S C R A T C H C O D I N G Activity Modular coding for dancing robot We broadcast 'LED_Shift' and 'Motor_Move' before. Now create a script for each broadcast. The script will start with the block 'when receiving LED_Shift' and 'when receiving Motor_Move'. Create the script below! Does this script make sense? In the previous scripting with a single script, the length of the script was long and the distinction between each action was not clear.
158 S C R A T C H C O D I N G K I T Logic CLASS 3 Boost Using a Wired Remote Control LESSON 10
S C R A T C H C O D I N G Making a Robot Activity introduction In this class, let's try activities using wired remote control. we will connect the remote control to the line follower we created earlier and move it. First, let's create a model by referring to the line-follower assembly diagram we made earlier.
160 CLASS 3 Wired Remote Control Connecting a Wired Remote Control Have you made all of your line followers? So, please refer to below and connect the wired remote to the main cell. The wired remote control can be plugged into the wired remote connector of the main cell. At this time, set the mode to 'F'. Wired remote control connector port Set ‘F’ mode Each button on the wired remote control can be moved by using the following functions.
S C R A T C H MEMO C O D I N G K I T
162 CLASS 3 MEMO
S C R A T C H MEMO C O D I N G K I T
FCC Information to User This equipment has been tested and found to comply with the limits for a Class B digital device, pursuant to Part 15 of the FCC Rules. These limits are designed to provide reasonable protection against harmful interference in a residential installation. This equipment generates, uses and can radiate radio frequency energy and, if not installed and used in accordance with the instructions, may cause harmful interference to radio communications.