7.8 Using the Remote Control

Making use of the received IR remote commands are done using the Logo commands “newir?” and “ir”. Here is an example:

to ir_control
    forever [
        if newir? [
            set command ir 
            if command = 128 [ beep ]
            if command = 129 [ a, on ]
            if command = 130 [ a, off ]
        ]
    ]
end

The above program checks if their is a new command from the remote control using the “newir?” in Logo and the “new infrared?” block in Tinker. When true, the infrared code is retrieved using “ir” in Logo and the “get infrared” block in Tinker. This infrared code is stored in the variable “command”. A sequence of “if” statements determine the received code and carries out different actions.

results matching ""

    No results matching ""