trying new library but won't create class instance

Go To Last Post
5 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello,

 

I am trying a new Arduino library and I am not super experienced with using libraries that don't have examples like this one but I'd really like to use it.

 

I made a test sketch and I am getting an error upon instantiation, I was hoping someone could help me get this working.  Here is the sketch and the error, and I attached the library files.

 

Sketch:

#include <MatrixCharlieplex.h>
MatrixCharlieplex testMatrix = MatrixCharlieplex(6, 30, 1);

void setup()
{
}

void loop()
{
  //  turn each led on sequentially:
  for (int row = 0; row < 6; row++)
  {
    for (int col = 0; col < 5; col++)
    {
      testMatrix.turnOn(row, col);
      delay(200);
    }
  }
}// end loop

 

Error:

testCharlieMatrix1:2: error: 'MatrixCharlieplex' does not name a type

 MatrixCharlieplex testMatrix = MatrixCharlieplex(6, 30, 1);

 ^

C:\Users\Perigalacticon\Documents\Arduino\sketches\testCharlieMatrix1\testCharlieMatrix1\testCharlieMatrix1.ino: In function 'void loop()':

testCharlieMatrix1:15: error: 'testMatrix' was not declared in this scope

       testMatrix.turnOn(row, col);

       ^

exit status 1
'MatrixCharlieplex' does not name a type

I am using the standard Arduino IDE v1.6.9 and compiling for "Arduino / Genuino Uno".

 

Thanks.

Attachment(s): 

This topic has a solution.
Last Edited: Fri. Jul 14, 2017 - 02:54 AM
This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

The class MatrixCharlieplext is in a separate namespace, namely ArduinoMatrixCharlieplex. Try

 

using namespace ArduinoMatrixCharlieplex;

MatrixCharlieplex testMatrix = MatrixCharlieplex(6, 30, 1);

"He used to carry his guitar in a gunny sack, or sit beneath the tree by the railroad track. Oh the engineers would see him sitting in the shade, Strumming with the rhythm that the drivers made. People passing by, they would stop and say, "Oh, my, what that little country boy could play!" [Chuck Berry]

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

My first guess is that the library'matrixCharlieplex. h' is not in one of the specific folders that Arduino looks for libraries.  There are two or three system folders (folders that are installed when the Arduino IDE is installed) and a user-specific folder for libraries.  If the library code is not in one of these specific folders, then it can't read them as instructed to by the #include statement.  When you go to try to instanciate an object ( or in simpler terms, to use the library), the compiler doesn't know how to make the object because it didn't read the code for making this object.  The compiler assumes that the class name is a user-defined type, and so gives the error "does not name a type".

 

The user-specified library is by default named "libraries" in the \Arduino Sketchbook folder.  If you move the Charlieplex library entire folder from where it is to  "C:\" ArduinoSketch\libraries\" then you will probably get the code to compile.   The two other folders that I know that hold Arduino libraries are:

  C:\arduino-9.9.99\libraries\   and      C:\arduino-9.9.99\hardware\arduino\avr\libraries\.   The \ard-n-n-n (numbers change by version)\ library has robot tools and common Arduino add-ons.  The other library (the deep library) has more system oriented things like Wire, SoftwareSerial, EEPROM, SPI, and a library called HID which allows the Leonardo to emulate a PC mouse or keyboard.

 

 

By the way,  if you are lighting a lot of LEDs then I recommend using inexpensive hardware chips like the MAX7219.  Here is an eBay listing of a chain of 8x8 LED modules where each LED in the module can be lighted, darkened, or read for it's current status (on or off) using SPI-based software. 

http://www.ebay.com/itm/MAX7219-...

 

Adafruit's LED module/MAX7219 library works will.   Hail to Limor Fried:  I'm sitting in the magazine section of the local library now where there's a picture of her in pink-haired glory on the cover of MAKE: magazine.

Last Edited: Fri. Jul 14, 2017 - 01:21 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks JohanEkdahl using namespace was the solution.  I also had to pass an array into the instance instead of an integer.  The library was in the right directory.  

 

The problem I have is I have 50 "semi-high-power" leds that operate at 5V and require 40mA each.  I am looking into the Maxim chips but it appears the MAX7219 can't do 5V or 40mA per LED.  I'm interested in charlieplexing these to reduce the power and pins required.

 

Thanks.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

@perigalacticon: One extra point to you for marking the problem solved!

 

Simonetta wrote:
My first guess is that the library'matrixCharlieplex. h' is not in one of the specific folders that Arduino looks for libraries.

Nope. the avr-g++ compiler emits a 'File not found' (or some such) error in that case (just as the avr-gcc C compiler does).

"He used to carry his guitar in a gunny sack, or sit beneath the tree by the railroad track. Oh the engineers would see him sitting in the shade, Strumming with the rhythm that the drivers made. People passing by, they would stop and say, "Oh, my, what that little country boy could play!" [Chuck Berry]

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]