Make Decisions Learning Outcomes Understand IR Sensor Program
- Slides: 22
Make Decisions
Learning Outcomes Ø Understand IR Sensor ØProgram Edison to detect obstacles and avoid them ØControl LED’s or generate sound if an obstacle detected Ø Learn the concept of the logic If Statement
Why IR sensor
What is IR sensor IR- Infrared Light : invisible to human Examples of invisible Lights : eyes • Radio Waves • X-rays • Microwave
Did you know? Although humans cannot see IR, some animals can. These animals use infrared to see their prey in all kinds of light, and weather conditions. Some snakes can see the body heat of their victims. This allows them to catch their prey. Piranha fish live in murky water and use IR to locate their prey. Mosquitoes use infrared to find the blood-rich parts of their prey.
IR sensor An infrared sensor measures infrared (IR) light radiating heat from objects in its field of view.
IR Sensor (1) No obstacle is in front of the sensor. (2) There is an obstacle.
Did you know? This is how we see: A torch shines light into dark places. When the light hits an object, some of the light bounces back to your eyes (sensors) so that you can see the object. If the object is further away, it is harder to see because less light bounces back to your eyes.
IR sensors in Edison Note r nso r e s t so en ligh s t f d Le re fra n i t Lef LED d e tr Lef d t re h Rig sor en s r red nso fra e n s i t ht gh Rig t li h Rig LED Edison is equipped with two obstacle sensors so it can detect obstacles in its path and avoid them. Edison emits infrared light from two, light-emitting diodes (LEDs), one on the left and one on the right. In between the two LEDs is an IR sensor. The sensor detects when IR is reflected from an obstacle. If the IR is reflected from the left LED, the obstacle is on the left. If the IR is reflected from the right LED, the obstacle is on the right. With these sensors, Edison can avoid collisions The obstacles need to be the same height (3. 5 cm/1. 5 in), or taller than Edison, for it to see them.
IF Statement Activity 1– Page 67 #-------Setup--------import Ed Ed. Edison. Version = Ed. V 2 Ed. Distance. Units = Ed. CM Ed. Tempo = Ed. TEMPO_MEDIUM #----Your code below-----Ed. Obstacle. Detection. Beam(Ed. ON) while True: if Ed. Read. Obstacle. Detection()== Ed. OBSTACLE_AHEAD: Ed. Play. Beep()
Python Comparison Operators Operator Description == Equal to != Not Equal to > Greater than < Less than >= Greater than and equal to <= Less than and equal to
Obstacles IR sensors in Edison Four Cases for Obstacles: • Obstacle ahead • Obstacle to the left • Obstacle to the right • No obstacle is detected
Activity 2– Page 69
IF – else Statement Activity 3– Page 70 Ed. Left. Led(Ed. ON) Ed. Right. Led(Ed. ON) else: Ed. Left. Led(Ed. OFF) Ed. Right. Led(Ed. OFF)
Multiple IF – else Statement Activity 4– Page 71
IF – elif - else Statement Page 72 while True: Obs = Ed. Read. Obstacle. Detection() # Read the obstacle sensor if Obs == Ed. OBSTACLE_AHEAD: # Check if the obstacle is ahead # If yes, then do case 1 elif Obs == Ed. OBSTACLE_RIGHT: # If not, check if it is on right # If yes, then do case 2 elif Obs == Ed. OBSTACLE_LEFT: # If not, check if it is on left # If yes, then do case 3 else: # Otherwise, # do case 4
Using Variables Page 73 #-------Setup--------import Ed Ed. Edison. Version = Ed. V 2 Ed. Distance. Units = Ed. CM Ed. Tempo = Ed. TEMPO_MEDIUM #----Your code below-----Ed. Obstacle. Detection. Beam(Ed. ON) while True: Obs = Ed. Read. Obstacle. Detection() if Obs == Ed. OBSTACLE_AHEAD: Ed. Play. Beep() Ed. Left. Led(Ed. OFF) Ed. Right. Led(Ed. OFF) elif Obs == Ed. OBSTACLE_RIGHT: Ed. Left. Led(Ed. OFF) Ed. Right. Led(Ed. ON) elif Obs == Ed. OBSTACLE_LEFT: Ed. Left. Led(Ed. ON) Ed. Right. Led(Ed. OFF) else: Ed. Left. Led(Ed. OFF) Ed. Right. Led(Ed. OFF) Ed. Time. Wait(200, Ed. TIME_MILLISECONDS)
Page 74 Group Work 1. Read exercise page 74 2. Discuss in your group 3. Program your Edison 4. Draw a line for your robot while moving 5. Evaluate the program and test
Step – by - Step Page 74 #-------Setup--------import Ed Ed. Edison. Version = Ed. V 2 Ed. Distance. Units = Ed. CM Ed. Tempo = Ed. TEMPO_MEDIUM #----Your code below-----Ed. Obstacle. Detection. Beam(Ed. ON) while True: Obs = Ed. Read. Obstacle. Detection() if Obs == Ed. OBSTACLE_AHEAD: Ed. Drive(Ed. BACKWARD_RIGHT, Ed. SPEED_5, Ed. DISTANCE_UNLIMITED) elif Obs == Ed. OBSTACLE_RIGHT: Ed. Drive(Ed. FORWARD_LEFT, Ed. SPEED_5, Ed. DISTANCE_UNLIMITED) elif Obs == Ed. OBSTACLE_LEFT: Ed. Drive(Ed. FORWARD_RIGHT, Ed. SPEED_5, Ed. DISTANCE_UNLIMITED) else: Ed. Drive(Ed. FORWARD, Ed. SPEED_5, Ed. DISTANCE_UNLIMITED) Ed. Time. Wait(200, Ed. TIME_MILLISECONDS)
End-of-unit Assessment
#-------Setup--------import Ed Ed. Edison. Version = Ed. V 2 Ed. Distance. Units = Ed. CM Ed. Tempo = Ed. TEMPO_MEDIUM #----Your code below-----Ed. Obstacle. Detection. Beam(Ed. ON) while True: Obs = Ed. Read. Obstacle. Detection() if Obs == Ed. OBSTACLE_AHEAD: Ed. Play. Beep() Ed. Left. Led(Ed. OFF) Ed. Right. Led(Ed. OFF) if Obs == Ed. OBSTACLE_RIGHT: Ed. Left. Led(Ed. OFF) Ed. Right. Led(Ed. ON) if Obs == Ed. OBSTACLE_LEFT: Ed. Left. Led(Ed. ON) Ed. Right. Led(Ed. OFF) if Obs == Ed. OBSTACLE_NONE: Ed. Left. Led(Ed. OFF) Ed. Right. Led(Ed. OFF) Ed. Time. Wait(200, Ed. TIME_MILLISECONDS)
- Poster making meaning
- To understand recursion you must understand recursion
- Screening decisions and preference decisions
- Make me understand
- Make me understand
- Make me understand
- Make me understand
- Make me understand
- Make me understand
- People with political savvy make decisions that
- Intensity of market coverage
- Selective distribution channel
- To make place decisions, marketers select the right
- To make place decisions marketers select the right
- Where do the mi'kmaq live
- Examples of learning outcomes
- Water cycle learning outcomes
- Learning objectives for notice writing
- Objective of swot
- Objective of teaching rhymes
- Planning goals and learning outcomes
- Photosynthesis takes place in
- Learning objectives of nutrition in plants class 7