handyboard.com / cricket
home
about
documentation
program
bus
faq
download
get one
build
tech
links
discuss

BUS

Intro LED Number Display Lamp/Relay Driver Motor/Sensor Expansion

LED Number Display for the Handy Cricket

4-Digit LED Number Display for the Handy Cricket

Features

  • Standard decimal mode shows numbers from 0 to 9999 on bright red 0.5” LED display

  • Powered from Handy Cricket using built-in 8” cable that plugs into Cricket's Expansion Bus.

  • Auto-off function and seven brightness settings to help save power

  • Hexadecimal mode prints full range of 16-bit values from 0000 to FFFF

  • “Raw bits” mode allows you to illuminate any segments you like on each of the four 7-segment digits

  • Up to two displays may be driven from one Handy Cricket

  • Built-in Bus Jack allows additional bus devices to be daisy-chained from the Display.

 

How to Use the Display

Plugging It In

The 4-Digit LED Display for the Handy Cricket is quite easy to use. Start off by plugging it into your Handy Cricket. You can use either bus port – they're both the same.

Turn on the Cricket, and the display should show a rectangle of illuminated segments. This is its power-on indicator.

Displaying Numbers

Now copy the following Logo driver procedure into your Cricket Programs window:

to display :n
  bsend $110
  bsend 0
  bsend high-byte :n
  bsend low-byte :n
end

Download to put this program into the Cricket, and then try it out using the Command Center. Type:

display 7

and you should see the number 7 on the display!

Displaying Sensor Values

Let's try something more useful – like displaying a sensor value. Find a Cricket light sensor and plug it into sensor port A. Now type the following statement into the Command Center:

loop [display sensora wait 1]

The display will now continuously show the value of sensor A, updating ten times per second.

Controlling Brightness

It's possible to adjust the brightness of the digits on the Display. When the Display is first turned on, it uses a mid-range level which is a good compromise between brightness and battery drain.

But you can adjust the brightness up and down depending on your application. Copy the following procedure into the Cricket Programs window:

to brightness :n
  bsend $110
  bsend $80
  bsend 0
  bsend :n
end

Brightness levels range from 1 (least brightness) to 7 (highest brightness). When the Display is first turned on, it is set to brightness level 4.

In order to preserve battery power, the Display will automatically turn off a minute after the last time it receives a command. If you have an application that requires the display to be on continually, simply put the display command into a loop so that it's issued more than once a minute, and your display will stay on.

 

That's all there is to it! There are some advanced features, which are described below, but for basic use of the Handy Cricket LED Number Display, you are already set.

 

 

 

Advanced Features

This section explains three advanced modes of the Handy Cricket LED Number Display:

  • Displaying Hexadecimal Numbers
  • Displaying Arbitrary Patterns
  • Using Two Displays on One Cricket

Displaying Hexadecimal Numbers

The LED Number Display can show the Cricket's 16-bit values in a hexadecimal format. This is useful for displaying numbers outside of the 0 to 9999 decimal range, or for displaying values that are easier to read if show in hex.

The following driver program tells the display to show a value in hexadecimal:

to display-hex :n
  bsend $110
  bsend 32
  bsend high-byte :n
  bsend low-byte :n
end

Displaying Arbitrary Patterns

The LED Number Display has a mode that lets you decide exactly which segments to light up. This lets you make arbitrary patterns or display alphabetic-style information.

The following display-bits procedure does the magic:

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

The display-bits procedure takes four inputs—a byte for each of the four 7-segment displays. Each byte controls the 7 segments of a digit according to the following diagram:

                   bit 0
                 ----------
                |          |
                |          |
             5  |          |  1
                |    6     |
                 ----------
                |          |
                |          |
             4  |          |  2
                |    3     |
                 ----------  

So, for example, to form the uppercase letter 'A,' (all segments but bit 3 lit), one would use the value $77 (the '$' symbol in Cricket Logo indicates a hexadecimal value).

For another example, the following procedure call will show 'Abcd' on the display:

display-bits $77 $7c $58 $5e

All sorts of uses are possible using this display mode.

Using Two Displays on One Cricket

There are two aspects to using two Displays from a single Cricket. First, a Display must have its address ID changed from the default ID of 1 to the optional ID of 2. Second, a slightly different set of procedures must be used for addressing the two displays.

Changing Address ID to 2. When shipped from the factory, all Displays are set to address 1. By cutting a trace and installing a jumper, a Display can be set to address 2. Then, two displays on connected to the same Cricket (one with address 1, and the other with address 2) can be issued commands independently.

The image below shows where to make the modifications to a Display to change it to address 2. The image is from the upper right corner of the Display, when viewed from the back:

Driver Procedures for Displays 1 and 2. The driver programs provided so far will work with a display set to either address ID 1 or 2. In order to separately issue commands to a particular display, different procedures must be used. Here they are:

to display1 :n
  bsend $110
  bsend 1
  bsend high-byte :n
  bsend low-byte :n
end

to display2 :n
  bsend $110
  bsend 2
  bsend high-byte :n
  bsend low-byte :n
end

to brightness1 :n
  bsend $110
  bsend $81
  bsend 0
  bsend :n
end

to brightness2 :n
  bsend $110
  bsend $82
  bsend 0
  bsend :n
end

to display-hex1 :n
  bsend $110
  bsend 33
  bsend high-byte :n
  bsend low-byte :n
end

to display-hex2 :n
  bsend $110
  bsend 34
  bsend high-byte :n
  bsend low-byte :n
end

to display-bits1 :d1 :d2 :d3 :d4
  bsend $110
  bsend 65
  bsend low-byte :d1
  bsend low-byte :d2
  bsend low-byte :d3
  bsend low-byte :d4
end

to display-bits2 :d1 :d2 :d3 :d4
  bsend $110
  bsend 66
  bsend low-byte :d1
  bsend low-byte :d2
  bsend low-byte :d3
  bsend low-byte :d4
end

Last modified: Friday, 03-Sep-2004 14:07:43 PDT by fredm