Professional Documents
Culture Documents
AIBot With Scratch 03
AIBot With Scratch 03
Learning Goal
Ask and wait, Variables, Repeat
✓ Using the ‘ask and wait’ block, You can control the AIBot by
asking for the axis and angle and receiving an answer.
But
www.jinirobot.com 3
2. 4 Keywords in Coding
Coding (programming) is not something you memorize like studying for a test.
Only through a lot of coding experience can naturally develop your skills.
www.jinirobot.com 4
3. What is Varibales?
1 Definition
✓ It’s a memory space assigned a name by a program to store data, such as number, text, etc.
[Code]
5
2
[code] → [Variables]
Enter ‘new variable name’ and click ‘ok’ New variable
→ [Make a Variable]
www.jinirobot.com 5
4. Preview
Mission Control the robot by asking for the axis and angle and receiving the answer!
[1] When the sprite asks for the desired axis and angle, the user enters the answer.
[2] These answers are saved in axis and angle variables respectively and control the robot using them.
www.jinirobot.com 6
5. Think about Algorithm
1 | When you start the program, it sets the module speed and returns to the home
position of all modules.
2 | Ask which axis you want, enter the answer, and save it in a variable.
3 | Ask at what angle you want to move, enter the answer, and save it in a variable
4 | Control the robot using the axis and angle saved in variables.
www.jinirobot.com 7
6. Sprites & Blocks
Category Block
AIBot
Sensing
Variables
Control
www.jinirobot.com 8
7. Ready to Code
1 Add Sprites
Click ‘Choose
2
a sprite’
Search and
3
select sprites
www.jinirobot.com 9
7. Ready to Code
2 Add Variables
3
axis
2 Select
1
module speed
Drga
&1drop
1
Drga
&1drop
3
www.jinirobot.com 11
8. Make Code
Step.1 Control and move the 1st-axis to the desired angle.
① Wait for the robot to perform the action of returning to home position.
www.jinirobot.com 12
8. Make Code
Step.2 Move other axes to the desired angle.
- What code can you modify in <Step.1> to move another axis?
주의!! The gripper angle of Module 4 can only be entered between 0 and 90 degrees.
If you input more than 90°, the motor will overheat and cause failure.
www.jinirobot.com 13
8. Make Code
Step.2 Save the selected axis and angle using variables and then move the robot.
① Initialization of variables
- Initialize [Axis] to 0 and [Angle] to 90.
② When the sprite asks for the axis the user wants to move and enters
the answer, this answer is saved in the variable [axis].
① ③ When the sprite asks for the angle the user wants to move and enters
the answer, this answer is saved in the variable [angle].
③
④ Control the robot using two variables: [Axis] and [Angle].
④
www.jinirobot.com 14
8. Make Code
Step.4 You can continue to control the robot using loops.
②
www.jinirobot.com 15
9. Completed Code
www.jinirobot.com 16
10. [Experiential Program] Control AIBoy by Angle
[2] When the user selects an axis and enters an angle value as the answer,
the robot will be controlled with the angle you entered for the selected axis.
www.jinirobot.com 17
10. Experiential Program: AIBot Control by Angle
Click ‘English
1 3
in upper menu bar
4
2 Click & download
[download file]
www.jinirobot.com 18