An introduction to basic logic and how robots make simple decisions based on conditions.
Have you ever wondered how a tablet knows to turn on when you touch the screen, or how a smart nightlight knows to glow only when the room gets dark? It isn't magic—it's the secret language of 'If' and 'Then'!
Robots and computers don't have brains like humans. They can't just 'guess' what to do. Instead, they follow a special kind of logic called a condition. A condition is a rule that tells a robot exactly when to perform an action. We use two very important words to build these rules: If and Then. The If part is the 'trigger' (what happens first), and the Then part is the 'action' (what the robot does next). Think of it like a light switch: If you flip the switch up, Then the light turns on!
Imagine you have a robot that helps you get snacks. You have to give it a clear rule: 1. If the clock says PM, 2. Then the robot gives you an apple.
In this case, the 'If' is the time, and the 'Then' is the snack!
Quick Check
In the sentence 'If the door is open, then the alarm beeps,' what is the 'Then' (the action)?
Answer
The alarm beeps.
Programmers use If/Then logic to make video games fun. Every time you play, the computer is checking hundreds of rules every second! For example, in a racing game, the computer might check: If the car touches the grass, Then the speed changes from to . This makes the car go slower because grass is harder to drive on than a road. By using these rules, we can create a world where things happen for a reason.
Let's look at how a game counts your score: 1. Start with a score of . 2. If the player touches a gold star, 3. Then the new score is . 4. If the player touches a red spike, 5. Then the player goes back to the start.
Quick Check
If your score is and you touch a gold star, what is your new score?
Answer
6
You are surrounded by 'If/Then' logic every day! Many machines use sensors to 'see' or 'feel' the world around them. A sensor is like a robot's eye or ear. For example, an automatic door at a grocery store has a motion sensor. If the sensor detects a person walking toward the door, Then the motor slides the door open. Without these rules, the robot wouldn't know when to move!
A robot vacuum needs to clean your house without getting stuck. It uses multiple rules at once: 1. If the sensor feels a wall in front, 2. Then the vacuum turns degrees to the left. 3. If the battery is less than , 4. Then the vacuum drives back to its charger.
Which word represents the 'trigger' or the thing that must happen first?
Look at this rule: 'If the score is , then you win!' What happens if your score is only ?
A robot vacuum uses sensors to help it follow its If/Then rules.
Review Tomorrow
Tomorrow morning, try to find one thing in your house that uses 'If/Then' logic. Is it the toaster? The microwave? The porch light?
Practice Activity
Play a game of 'Robot Says' with a friend. Give them a rule like: 'If I clap my hands, then you must jump once!'