Thursday, June 3, 2010

What if you want the LED display to not display anything?

Problem

The LED display will automatically turn off after a little while if it's idle to conserve battery power. But how can you make it go blank right away?

Solution

You have to use a procedure called "display-bits." Here it is:
to display-bits :d1 :d2 :d3 :d4
bsend $110
bsend 64
bsend low-byte :d1
bsend low-byte :d2
bsend low-byte :d3
bsend low-byte :d4
end

Bits are the individual bars that can light up in each of the four spaces. D1, d2, d3, and d4 stand for the four spaces. To make all of the bits turn off, you would send the command "display-bits $00 $00 $00 $00."

Applying the solution

If you only sent this command, the Cricket wouldn't know how to "display-bits," so here is an example of how you use this command. Notice that you have to include the "display-bits" procedure because it's acting as a sub-procedure to "count." The "count" procedure will make it count 1, 2, then go blank.
to count
display 1
wait 5
display 2
wait 5
display-bits $00 $00 $00 $00
end

to display-bits :d1 :d2 :d3 :d4

bsend $110
bsend 64
bsend low-byte :d1
bsend low-byte :d2
bsend low-byte :d3
bsend low-byte :d4
end

No comments: