Review: Gravitech 7-Segment Arduino Shield

Hello Readers

In this article we examine the “7-Segment Arduino Shield” received for review from the team at Gravitech in the United States. This is an Arduino Uno/Duemilanove-type compatible shield that contains four very useful items:

  • Four 7-segment LED numerical displays – driven by the NXP SAA1064 LED display driver IC;
  • A large 10mm RGB LED;
  • A Microchip 24LC128 EEPROM, and
  • A TI TMP75 digital temperature sensor.
Apart from the LED all the other components are controlled via the I2C bus. So as well as being generally useful for experimenting, monitoring temperature and so on, this is an ideal board for Arduino and I2C bus practice. (If you have not done so already, consider reading our I2C tutorial,part one and two). Let’s look at the hardware, then move on to using the features.
As with other Gravitech products, the shield arrives in a reusable static shielding bag:
and here we have it:
The IC at the top-left of the shield is the TMP75 temperature sensor, bottom-left is the 24LC128 EEPROM, and the whopper below the first two digits is the NXP SAA1064. The shield layout is very neat and clean, and the white finish is a pleasant change compared to the usual black or green Arduino shields out there. The PWR LED is a blue colour. The only issue from a hardware perspective was that the component leads were not trimmed at the factory, which caused an issue when the shield was inserted into an Ethernet shield. This is easily solved by clipping the leads yourself:
Here is the shield in operation using the supplied demonstration sketch. The temperature is displayed in Celsius, with the LED changing colour depending on the temperature:

That is all very good, but how do we use the features of the board? Let’s look at each of the aforementioned features individually. First of all, the numeric display. The four seven-segment LED displays are controlled by the NXP SAA1064 LED display driver (data sheet (.pdf)). I have written a separate tutorial on how to use this IC, and it is completely compatible with this shield. So visit the tutorial here and put the numbers to work! Please note the I2C bus address for the SAA1064  is 0×38.

Next we have the RGB LED. Red, green and blue are connected to digital pins 3, 5 and 6 respectively. These are also pulse-width modulation pins, so you can have altering the brightness. Here is a simple demonstration sketch (download):

/* PWM LED example sketch for Gravitech 7-segment Shield - http://www.gravitech.us/7segmentshield.html */  int red = 3; // the pins for the LED int green = 5; int blue = 6; int i = 0; // for loops int j = 0;  void setup() { pinMode(red, OUTPUT); // tell Arduino LED is an output pinMode(green, OUTPUT); pinMode(blue, OUTPUT); } void loop() { // first, cycle up each primary colour twice for (j = 1; j < 2; j++) {  // loop 5 times for (i = 0; i < 255; i++) { // loop from 0 to 254 (fade in) analogWrite(red, i);      // set the LED brightness delay(20); // Wait 10ms because analogWrite isn't instant } analogWrite(red,0); delay (20); for (i = 0; i < 255; i++) { // loop from 0 to 254 (fade in) analogWrite(green, i);      // set the LED brightness delay(20); // Wait 10ms because analogWrite isn't instant } delay (20); analogWrite(green,0); for (i = 0; i < 255; i++) { // loop from 0 to 254 (fade in) analogWrite(blue, i);      // set the LED brightness delay(20); // Wait 10ms because analogWrite isn't instant } delay (20); analogWrite(blue,0); } // psychadelic time for (j = 1; j < 10000; j++) { analogWrite(red,random(255)); // set red at random brightness between 0 and 254 delay (random(21)+100);           // wait for a random duration between 10 and 30 milliseconds analogWrite(green,random(255)); delay (random(21)+100); analogWrite(blue,random(255)); delay (random(21)+100); } }

And for the curious, here it is in action:

Next, the Microchip 24LC128 EEPROM. It has 128kbit storage space, which translates to 16 kilobytes. The I2C bus address is 0×50. Once again there is a complete explanation of how to use this sort of EEPROM in another tutorial – check it out. But for quick reference the following demonstration sketch writes the numbers 0~255 to memory locations 0~255 (download):

/* 24LC128 EEPROM example sketch for Gravitech 7-segment Shield - http://www.gravitech.us/7segmentshield.html */  #include      // for I2C #define chip1 0x50    // device address for 24LC128  // always have your values in variables unsigned int pointer = 69; // we need this to be unsigned, as you may have an address > 32767 byte d=0; // example variable to handle data going in and out of EERPROMS  void setup() { Serial.begin(57600); // for screen output Wire.begin();   // wake up, I2C! }  void writeData(int device, unsigned int add, byte data) // writes a byte of data 'data' to the chip at I2C address 'device', in memory location 'add' { Wire.beginTransmission(device); Wire.send((int)(add >> 8));   // left-part of pointer address Wire.send((int)(add & 0xFF)); // and the right Wire.send(data); Wire.endTransmission(); delay(10); }  byte readData(int device, unsigned int add) // reads a byte of data from memory location 'add' in chip at I2C address 'device' { byte result;  // returned value Wire.beginTransmission(device); //  these three lines set the pointer position in the EEPROM Wire.send((int)(add >> 8));   // left-part of pointer address Wire.send((int)(add & 0xFF)); // and the right Wire.endTransmission(); Wire.requestFrom(device,1); // now get the byte of data... result = Wire.receive(); return result; // and return it as a result of the function readData }  void loop() { Serial.println("Writing data..."); for (int a=0; a<255; a++) { writeData(chip1,a,a); } Serial.println("Reading data..."); for (int a=0; a<255; a++) { Serial.print("EEPROM pointer "); Serial.print(a); Serial.print(" holds "); d=readData(chip1,a); Serial.println(d, DEC); } }
Although there is 16 kilobytes of memory the sketch only writes and reads to the first 255 locations. Each location can store a byte of value between zero and 255. Here is a screen shot of the serial monitor results (click to enlarge):

And now time to work with the Texas Instruments TMP75 temperature sensor (data sheet.pdf). It has a reasonable operating temperature range of between -40 and 125 degrees Celsius – however this would exceed the range in which your Arduino is capable of working, so no leaving the shield on the car dashboard during a hot summer’s day. The I2C bus address for the TMP75 is 0×49. We will deconstruct the Gravitechdemonstration sketch to explain how the temperature works.

The TMP75 needs to be initialised before measurement can take place, by sending the following data:

Wire.beginTransmission(0x49);
Wire.send(1); Wire.send(B01100000); Wire.endTransmission(); Wire.beginTransmission(0x49); Wire.send(0); Wire.endTransmission();

The temperature data is received in two bytes of data, as it spans 12 bits. Thankfully the demonstration sketch has done the work for us. Have a look at the Cal_temp() function, which converts the two raw bytes of data from the TMP75. There is some bitwise arithmetic in there, however if you are not keen on going down to that level, it is easy enough to cut and paste the temperature and numeric display functions.  Here is a quick video of the demonstration sketch in action:

So there you have it – another useful and educational shield for use with your Arduino. If you have any questions or enquiries please direct them to Gravitech via their contact page. Gravitech products including the 7-segment shield are available directly from their website or these distributors.

As always, thank you for reading and I look forward to your comments and so on. Furthermore, don’t be shy in pointing out errors or places that could use improvement. Please subscribe using one of the methods at the top-right of this web page to receive updates on new posts, follow on twitterfacebook, or join our Google Group.

[Disclaimer – the shield reviewed in this article was a  promotional consideration made available by Gravitech]

High resolution photos are available on flickr.

Otherwise, have fun, be good to each other – and make something! 

Advertisements
By John Boxall

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s