Introduction: The Magic Treasure Chest

This is an automatic chest opener

Step 1: Base

Build a base out of wooden cardboard

Use glue to hold the sides up

The height is 20cm long

The length of the base is 17cm long

The length of the box is 12cm long

Step 2: Server Motor

Add the server motor to the back of the box

Plug it into box 12

Slide it into the side of the box

Step 3: Lever

This is the lever that is going to open and close the chest


Step 4: Program

'-----[ Variables ]------------------------

irDetectLeft VAR Bit

irDetectRight VAR Bit

robot VAR Word




'-----[ Initialization ]--------------------

DEBUG "Testing piezospeaker..." 'let you know if it works

FREQOUT 4, 2000, 3000 '

DEBUG CLS,

"IR DETECTERS", CR,

"Left Right", CR,

"---- -----"

' -----[ Main Routine ]---------------------

Do ' start of forever repeat loop

FREQOUT 8, 1, 38500 'sends out a infrared light

irDetectLeft = IN9 ' the variables

FREQOUT 2, 1, 38500 'sends out a infrared light

irDetectRight = IN0 ' the variables



FOR robot = 1 TO 120

PULSOUT 12, 850 'FWD

NEXT

IF (irDetectLeft = 0)THEN

FOR robot = 1 TO 120

PULSOUT 12, 650 'FWD

NEXT

ENDIF

IF (irDetectRight = 0)THEN

FOR robot = 1 TO 120

PULSOUT 12, 650 'FWD

NEXT

ENDIF

IF (irDetectLeft = 0)THEN

FOR robot = 1 TO 24

PULSOUT 12, 850 ' turn right

PAUSE 20

NEXT

ENDIF

IF (irDetectRight = 0) THEN

FOR robot = 1 TO 25

PULSOUT 12, 850 'turn right

PAUSE 20

NEXT

ENDIF 'end of conditional statent

LOOP'end of forever repeat loop