The Magic Treasure Chest

by damianm85560 in Craft > Cardboard

12 Views, 0 Favorites, 0 Comments

The Magic Treasure Chest

IMG_0410.jpeg
IMG_0412.jpeg
IMG_0411.jpeg

This is an automatic chest opener

Base

IMG_0240.jpeg
IMG_0239.jpeg

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

Server Motor

IMG_0412.jpeg
IMG_0415.jpeg
IMG_0417.jpeg

Add the server motor to the back of the box

Plug it into box 12

Slide it into the side of the box

Lever

IMG_0418.jpeg
IMG_0419.jpeg

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


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