Elenco Snap Circuits SnapMicro ® I Standard User Manual

Page 69

Advertising
background image

68

Program in Basic for Green Power Meter.




























The program will take 24 hours before it records the

first day’s cost. To speed up program for testing

purposes, change the second pause from 59940 to 1. After testing replace original value.

setint

Syntax:

SETINT OFF
SETINT i n p u t , m a s k

- input is a variable/constant (0-255) which specifies input condition.
- mask is variable/constant (0-255) which specifies the mask
Function:
Interrupt on a certain inputs condition.
Information:
The setint command causes a polled interrupt on a certain input pin / flags
condition.
A polled interrupt is a quicker way of reacting to a particular input combination.
It is the only type of interrupt available in the PICAXE system. The inputs port is
checked between execution of each command line in the program, between each
note of a tune command, and continuously during any pause command. If the
particular inputs condition is true, a ‘gosub’ to the interrupt sub-procedure is
executed immediately. When the sub-procedure has been carried out, program
execution continues from the main program.
The interrupt inputs condition is any pattern of ‘0’s and ‘1’s on the input port,
masked by the byte ‘mask’. Therefore any bits masked by a ‘0’ in byte mask will be
ignored.
e.g.
to interrupt on input 3, high only in binary format

setint %00001000,%00001000 (In decimal = 8,8)


high only Input 3 Input 2 Input 1 Input 0


to interrupt on input 1 low only

setint %00000000,%00000010 (In decimal = 0,2)

to interrupt on input 0 high, input 1 high and input 2 low

setint % 0 0 0 0 0 0 1 1 , % 0 0 0 0 0 1 1 1 (In decimal = 3,7)


128 64 32 16 8 4 2 1 or 2+1=3

4+2+1=7

add position values that are ones to convert from binary to decimal.

Change the word “decimal” to a “.” before downloading.

Lamp Wattage

Cost per kilowatt

hour to nearest
penny.

Advertising