Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 2

Inventor 4 Exercises (a) Containers: Containers enable Robolab programs to store variables and values, and perform arithmetic

and comparisons. here are three containers! red, "ello#, and blue. $s an example, the follo#ing program counts the number of times a button has been released ( stored in the red container), and displa"s it on the RC% screen. &hen the number exceeds a threshold, an alert is sounded.
If m ax reached, play notes and end Clear container #isplay count on screen of $C% when button released add to! red" container 4 4 Com pare to m ax 2 if less than m ax,beep and go back to wait for m ore counts

Sample Program- Containers

Challenge: 'odif" the above program so that #hen a flashlight beam shining on a light sensor is interrupted ( times, a complete song is pla"ed or the vehicle runs a#a".

Inventor 4 Exercise ): Events Events are a #a" of monitoring a sensor #hile doing something else in an endless (*ump and land) loop. Events are a sub!menu of the structures menu. &hen the event occurs, the program *umps out of the loop to an event landing, #here it then does something else:

Challenge: +ave "our robot follo# the line. &hen a flashlight is shone on it, have do the sumo!bot routine Example ):
Set up pressed e'ent and start m onitoring ) ollow the line

*+

when e'ent happens, (um p to here

&nd do sum o-bot routine

You might also like