Shop OBEX P1 Docs P2 Docs Learn Events
PENGUIN ROBOT Body Switch - the Code — Parallax Forums

PENGUIN ROBOT Body Switch - the Code

HumanoidoHumanoido Posts: 5,770
edited 2007-10-25 04:45 in Robotics
The Amazing Penguin Body Switch
penguin_body_switch.bpx
Turns Penguins' body into a virtual on/off switch


Penguin now has a software latching on/off switch
using this code! The program is part of the Virtual
Reality series, adding VR hardware to Penguin
using only software. It's also a compass program
in the code series.

Turn Penguins body to switch on or off! Now you
can control sections of code, turning things on or
off, using this technique!

humanoido

' This is a virtual on/off switch using Penguins' body and compass.
' To turn on the switch, move Penguins' body until it faces North.
' A high pitch tone is heard. To turn off the switch, move Penguin
' to South. A low pitch tone is heard. The switch is latching. Once
' it's on, it stays on until switched off. The switch condition is
' reported to the Debug screen.

' The tone will sound when the body is within the specified range.
' When the target body switch position is precisely reached, the tone
' will become steady. To squelch the tone, the body is offset.

' This program requires compass calibration. 

' 90  - East
' 180 - South
' 270 - West
' 360 - North

' If the compass angle is from 0 to 5
' or 355 TO 360 then switch on (North).
' If the compass angle is from 175 to 180
' or 180 to 185 then switch off (South)

' Expand the code to create a VR multifunction switch, and turn
' multiple elements on and off!
Sign In or Register to comment.