Code confusion with 1.2" LED Matrix w/I2C Backpack

EL Wire/Tape/Panels, LEDs, pixels and strips, LCDs and TFTs, etc products from Adafruit

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
billf
 
Posts: 51
Joined: Mon Jun 20, 2011 9:58 am

Code confusion with 1.2" LED Matrix w/I2C Backpack

Post by billf »

Product: PID 1051 Adafruit small 1.2” 8x8 LED Matrix w/I2C Backpack - Yellow-Green


In the directory user/bill/arduino-0022/arduino-0022/libraries I have the following folders:

Adafruit_GFX
Adafruit_LEDBackpack
AFMotor
ArduinoTestSuite
EEPROM
Ethernet
Firmata
Matrix
MiniSD
PN532
SD
Servo
SoftwareSerial
SPI
Sprite
Stepper
TFTLCD
TimerOne
TouchScreen
Wire


In the Adafruit_GFX folder, I have the following files:

Adafruit_GFX ( a CPP file )
Adafruit_GFX ( a H file)
glcdfont.c (a C file)
license
README

In the Adafruit_LEDBackpack folder, I have the following files:

Adafruit_LEDBackpack ( a CPP file)
Adafruit_LEDBackpack ( a H file)
license
README
examples (this is a folder)

Inside the Adafruit_LEDBackpack/README file, it has the following text:


----------------begin text------------------------------------------------------------------

This is a library for the Adafruit LED Backpacks
This library works with the Adafruit Mini 8x8 and 7-Segment LED Backpacks
----> http://www.adafruit.com/products/881
----> http://www.adafruit.com/products/880
----> http://www.adafruit.com/products/879
----> http://www.adafruit.com/products/878
----> http://www.adafruit.com/products/872
----> http://www.adafruit.com/products/871
----> http://www.adafruit.com/products/870

These displays use I2C to communicate, 2 pins are required to
interface. There are multiple selectable I2C addresses. For backpacks
with 2 Address Select pins: 0x70, 0x71, 0x72 or 0x73. For backpacks
with 3 Address Select pins: 0x70 thru 0x77


Written by Limor Fried/Ladyada for Adafruit Industries.
MIT license, all text above must be included in any redistribution

To download. click the DOWNLOADS button in the top right corner, rename the uncompressed folder Adafruit_LEDBackpack. Check that the Adafruit_LEDBackpack folder contains Adafruit_LEDBackpack.cpp and Adafruit_LEDBackpack.

Place the Adafruit_LEDBackpack library folder your <arduinosketchfolder>/libraries/ folder. You may need to create the libraries subfolder if its your first library. Restart the IDE

**** Also requires the Adafruit_GFX library for Arduino. ****
Download it from here:
https://github.com/adafruit/Adafruit-GFX-Library


----------------end text------------------------------------------------------------------

Question number 1 - Is this the correct library because it does NOT list the product I’m trying to work with. But when I follow the instructions on adafruit.com, my product (PID 1051) points me to this library.


When I open the Adafruit_LEDBackpack/examples folder, I see the following file folders:

bicolor8x8
HT16K33
matrix8x8
roboface
sevenseg
wavface

If I open the matrix8x8 folder, there is one Arduino sketch file inside:

matrix8x8

If I copy this to where I keep all my Arduino sketches, and I try to compile it, I get the following error messages:

----------------begin text------------------------------------------------------------------
matrix8x8.ino:23:34: error: Adafruit_LEDBackpack.h: No such file or directory
matrix8x8:26: error: 'Adafruit_8x8matrix' does not name a type
matrix8x8.ino: In function 'void setup()':
matrix8x8:32: error: 'matrix' was not declared in this scope
matrix8x8.ino: In function 'void loop()':
matrix8x8:65: error: 'matrix' was not declared in this scope
matrix8x8:66: error: 'LED_ON' was not declared in this scope
matrix8x8_modified.ino: At global scope:
matrix8x8_modified:28: error: 'Adafruit_8x8matrix' does not name a type
matrix8x8_modified.ino: In function 'void setup()':
matrix8x8_modified:30: error: redefinition of 'void setup()'
matrix8x8:28: error: 'void setup()' previously defined here
matrix8x8_modified:34: error: 'matrix' was not declared in this scope
matrix8x8_modified.ino: At global scope:
matrix8x8_modified:38: error: redefinition of 'const uint8_t smile_bmp []'
matrix8x8:36: error: 'const uint8_t smile_bmp [8]' previously defined here
matrix8x8_modified:47: error: redefinition of 'const uint8_t neutral_bmp []'
matrix8x8:45: error: 'const uint8_t neutral_bmp [8]' previously defined here
matrix8x8_modified:56: error: redefinition of 'const uint8_t frown_bmp []'
matrix8x8:54: error: 'const uint8_t frown_bmp [8]' previously defined here
matrix8x8_modified.ino: In function 'void loop()':
matrix8x8_modified:66: error: redefinition of 'void loop()'
matrix8x8:64: error: 'void loop()' previously defined here
matrix8x8_modified:67: error: 'matrix' was not declared in this scope
matrix8x8_modified:68: error: 'LED_ON' was not declared in this scope
----------------end text------------------------------------------------------------------
Looking at the first error, it can’t find Adafruit_LEDBackpack.h

If I modify the code in the sketch from this:

#include "Adafruit_LEDBackpack.h"

to this:

#include <Adafruit_LEDBackpack.h>

then I get this for error messages:

----------------begin text------------------------------------------------------------------
matrix8x8:27: error: 'Adafruit_8x8matrix' does not name a type
matrix8x8.ino: In function 'void setup()':
matrix8x8:33: error: 'matrix' was not declared in this scope
matrix8x8.ino: In function 'void loop()':
matrix8x8:66: error: 'matrix' was not declared in this scope
matrix8x8:67: error: 'LED_ON' was not declared in this scope
matrix8x8_modified.ino: At global scope:
matrix8x8_modified:28: error: 'Adafruit_8x8matrix' does not name a type
matrix8x8_modified.ino: In function 'void setup()':
matrix8x8_modified:30: error: redefinition of 'void setup()'
matrix8x8:29: error: 'void setup()' previously defined here
matrix8x8_modified:34: error: 'matrix' was not declared in this scope
matrix8x8_modified.ino: At global scope:
matrix8x8_modified:38: error: redefinition of 'const uint8_t smile_bmp []'
matrix8x8:37: error: 'const uint8_t smile_bmp [8]' previously defined here
matrix8x8_modified:47: error: redefinition of 'const uint8_t neutral_bmp []'
matrix8x8:46: error: 'const uint8_t neutral_bmp [8]' previously defined here
matrix8x8_modified:56: error: redefinition of 'const uint8_t frown_bmp []'
matrix8x8:55: error: 'const uint8_t frown_bmp [8]' previously defined here
matrix8x8_modified.ino: In function 'void loop()':
matrix8x8_modified:66: error: redefinition of 'void loop()'
matrix8x8:65: error: 'void loop()' previously defined here
matrix8x8_modified:67: error: 'matrix' was not declared in this scope
matrix8x8_modified:68: error: 'LED_ON' was not declared in this scope


----------------end text------------------------------------------------------------------

At least I got rid of one error. Now it seems like it can find the file Adafruit_LEDBackpack.h

Question number 2: what is the difference between “ “ and < > in an #include statement?

But, bottom line, I can’t get the sketch called matrix8x8 to complile.

Question number 3: Is this the correct sketch to run for the hardware I have (PID 1051)?

Thank you for your help with this.

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: Code confusion with 1.2" LED Matrix w/I2C Backpack

Post by adafruit_support_mike »

Is this the path to your sketchbook directory?

Code: Select all

user/bill/arduino-0022/arduino-0022

User avatar
billf
 
Posts: 51
Joined: Mon Jun 20, 2011 9:58 am

Re: Code confusion with 1.2" LED Matrix w/I2C Backpack

Post by billf »

Mike, I'm not sure I am answering your question correctly, but here goes:

My sketches are in the following directory:

Libraries/Documents/Arduino

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: Code confusion with 1.2" LED Matrix w/I2C Backpack

Post by adafruit_support_mike »

That's a good answer.

In that same folder, you need a folder named 'libraries'. All the library folders you download need to go into that.

This tutorial has more information: http://learn.adafruit.com/adafruit-all- ... -libraries

User avatar
billf
 
Posts: 51
Joined: Mon Jun 20, 2011 9:58 am

Re: Code confusion with 1.2" LED Matrix w/I2C Backpack

Post by billf »

Mike, I read through the tutorial on libraries and I moved all my library folders over to

users/bill/documents/Arduino/libraries

Here are the folders that are in that 'libraries' folder:

Adafruit_GFX
Adafruit_LEDBackpack
AFMotor
ArduinoTestSuite
EEPROM
Ethernet
Firmata
Matrix
MiniSD
PN532
SD
Servo
SoftwareSerial
SPI
Sprite
Stepper
TFTLCD
TimerOne
TouchScreen
Wire
readme (this is a file, not a folder)


I tried to run the sketch called matrix8x8 because this is the one suggested for this hardware (PID 1051 which is really PID 1048 and PID 1045). It still worries me that inside the sketch it says the sketch is written for the following products:

870, 871, and 872.

Am I running the wrong sketch?

I guess it doesn't matter ---yet--- what hardware I am trying to use since the sketch will not compile. I get the following compile errors:

Code: Select all










C:\Users\Bill\Documents\Arduino\libraries\Adafruit_LEDBackpack\Adafruit_LEDBackpack.cpp: In member function 'void Adafruit_LEDBackpack::setBrightness(uint8_t)':
C:\Users\Bill\Documents\Arduino\libraries\Adafruit_LEDBackpack\Adafruit_LEDBackpack.cpp:52: error: 'class TwoWire' has no member named 'write'
C:\Users\Bill\Documents\Arduino\libraries\Adafruit_LEDBackpack\Adafruit_LEDBackpack.cpp: In member function 'void Adafruit_LEDBackpack::blinkRate(uint8_t)':
C:\Users\Bill\Documents\Arduino\libraries\Adafruit_LEDBackpack\Adafruit_LEDBackpack.cpp:60: error: 'class TwoWire' has no member named 'write'
C:\Users\Bill\Documents\Arduino\libraries\Adafruit_LEDBackpack\Adafruit_LEDBackpack.cpp: In member function 'void Adafruit_LEDBackpack::begin(uint8_t)':
C:\Users\Bill\Documents\Arduino\libraries\Adafruit_LEDBackpack\Adafruit_LEDBackpack.cpp:73: error: 'class TwoWire' has no member named 'write'
C:\Users\Bill\Documents\Arduino\libraries\Adafruit_LEDBackpack\Adafruit_LEDBackpack.cpp: In member function 'void Adafruit_LEDBackpack::writeDisplay()':
C:\Users\Bill\Documents\Arduino\libraries\Adafruit_LEDBackpack\Adafruit_LEDBackpack.cpp:82: error: 'class TwoWire' has no member named 'write'
C:\Users\Bill\Documents\Arduino\libraries\Adafruit_LEDBackpack\Adafruit_LEDBackpack.cpp:85: error: 'class TwoWire' has no member named 'write'
C:\Users\Bill\Documents\Arduino\libraries\Adafruit_LEDBackpack\Adafruit_LEDBackpack.cpp:86: error: 'class TwoWire' has no member named 'write'
I'm sort of stuck here trying to figure out what the error messages are trying to tell me.

Thank you for your help with this.

Bill

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: Code confusion with 1.2" LED Matrix w/I2C Backpack

Post by adafruit_support_mike »

The Arduino IDE already has a copy of the Wire library, so you don't need another one. The one you have may be causing the confusion.

Get rid of that then try again.

User avatar
billf
 
Posts: 51
Joined: Mon Jun 20, 2011 9:58 am

Re: Code confusion with 1.2" LED Matrix w/I2C Backpack

Post by billf »

Mike, that seems to have been the problem. The sketch now compiles and when I uploaded it, the 8x8 matrix is showing the demo graphics.

Thank you VERY much!!!!! I'm not sure how I would have figured that one out by myself. I really appreciate the support.

Bill

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: Code confusion with 1.2" LED Matrix w/I2C Backpack

Post by adafruit_support_mike »

Knowing stuff like that is why Ladyada and PT keep me around. ;-)

Glad to hear it's working for you. Happy hacking!

Locked
Please be positive and constructive with your questions and comments.

Return to “Glowy things (LCD, LED, TFT, EL) purchased at Adafruit”