Digital Sensors

From Smart Box
Jump to navigation Jump to search

The range of digital sensors allow simple on / off conditions to be detected. The sensors are connected between the pairs of red and yellow digital sensor sockets on the top of the box. When the sensor is in its ‘On’ condition the indicator on the box will light. The Smart Move software can detect the condition of the switch as ‘On’ or ‘Off’ or alternatively ‘1’ or ‘0’. Both these Smart Move program lines are valid:

IF SENSOR 1 IS ON THEN FORWARD A
IF SENSOR 1 = 1 THEN FORWARD A

Making your own sensors[edit]

Any device which completes a circuit between a red and yellow socket on Smart Box can be used as a digital sensor. This can be as simple as two contacts closing together. Switches can be manufactured using card and tin foil, pegs and drawing pins etc.

An example project[edit]

The following example uses three digital sensors and a buzzer to create a simple security system.

Sensors 0 and 1 are magnetic contact switches which will open as a door or window is opened. A push switch is connected to sensor 2 which is used to switch off the system. The Digital sensors can be ‘Labelled’ or given an alternative name using the LABEL command in Smart Move. This makes the sensors easier to identify. In the same way some of the Smart Move keywords can be changed. In this example the keyword OFF is changed to OPEN. The reference section gives more details.

Macintosh monitor window showing labels

Type in the following as direct commands

LABEL OFF open
LABEL SENSOR0 door
LABEL SENSOR1 window
LABEL SENSOR2 turnoff
LABEL OUTPUT0 buzzer

Type in all the procedures as shown then run the Alarm procedure.

Procedure: Alarm[edit]

REPEAT
IF DOOR IS OPEN THEN Soundalarm
IF WINDOW IS OPEN THEN Soundalarm
UNTIL TURNOFF IS ON
Stopalarm

Procedure: Soundalarm[edit]

SWITCH ON buzzer PULSE 50,50

Procedure: Stopalarm[edit]

SWITCH OFF buzzer