Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Arduino

  1. #1
    Junior Member Goxy's Avatar
    Join Date
    Apr 2014
    Location
    Czech Republic
    Posts
    11
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Arduino

    Is anyone here working by any chance working with Arduino ?
    So I bought a 8x8 Matrix LED, and I hooked it up with my Arduino, everything was cool, downloaded the needed libraries for the backpack and for the GTX.
    So pretty much the backpack works with 4pins:
    1. CLK (l2C clock)
    2. DAT (l2C data)
    3. GND
    4. VCC+ (5V or 3V)

    Connected everything, installed the libraries successfully. Tested it all the sketches and examples and they worked perfect.
    But here comes the problem so when I started creating my own patterns for the 8x8 matrix with code i came up with errors..
    Now while I was writing my code I was looking at what the original code of course so I could reference if any errors come up.

    #include <Wire.h>
    #include "Adafruit_LEDBackpack.h"
    #include "Adafruit_GTX.h"
     
    Adafruit_8x8matrix matrix = Adafruit_8x8matrix();
     
    void setup()
    {
       Serial.begin(9600);
       Serial.println("8x8 LED Matrix Test");
       matrix.begin(0x70);
    }
     
    static const uint8_t PROGMEM
       patern_bmp[] = 
       {
           B01010101,
           B00000000,
           B00000000,
           B00000000,
           B00000000,
           B00000000,
           B00000000,
           B00000000
       },
       patern2_bmp[] =
       }
           B01010101,
           B10101010,
           B00000000,
           B00000000,
           B00000000,
           B00000000,
           B00000000,
           B00000000
       },
       patern3_bmp[] =
       }
           B01010101,
           B10101010,
           B01010101,
           B00000000,
           B00000000,
           B00000000,
           B00000000,
           B00000000
       },
       patern4_bmp[] =
       }
           B01010101,
           B10101010,
           B01010101,
           B10101010,
           B00000000,
           B00000000,
           B00000000,
           B00000000
       },
       patern5_bmp[] =
       }
           B01010101,
           B10101010,
           B01010101,
           B10101010,
           B01010101,
           B00000000,
           B00000000,
           B00000000
       },
       patern6_bmp[] =
       }
           B01010101,
           B10101010,
           B01010101,
           B10101010,
           B01010101,
           B10101010,
           B00000000,
           B00000000
       },
       patern7_bmp[] =
       }
           B01010101,
           B10101010,
           B01010101,
           B10101010,
           B01010101,
           B10101010,
           B01010101,
           B00000000
       },
       patern8_bmp[] =
       }
           B01010101,
           B10101010,
           B01010101,
           B10101010,
           B01010101,
           B10101010,
           B01010101,
           B10101010
       };
     
    void loop()
    {
       matrix.clean();
       matrix.dawBitmap(0, 0, patern_bmp, 8, 8, LED_ON);
       matrix.writeDisplay();
       delay(500);
     
       matrix.clean();
       matrix.dawBitmap(0, 0, patern2_bmp, 8, 8, LED_ON);
       matrix.writeDisplay();
       delay(500);
     
       matrix.clean();
       matrix.dawBitmap(0, 0, patern3_bmp, 8, 8, LED_ON);
       matrix.writeDisplay();
       delay(500);
     
       matrix.clean();
       matrix.dawBitmap(0, 0, patern4_bmp, 8, 8, LED_ON);
       matrix.writeDisplay();
       delay(500);
     
       matrix.clean();
       matrix.dawBitmap(0, 0, patern5_bmp, 8, 8, LED_ON);
       matrix.writeDisplay();
       delay(500);
     
       matrix.clean();
       matrix.dawBitmap(0, 0, patern6_bmp, 8, 8, LED_ON);
       matrix.writeDisplay();
       delay(500);
     
       matrix.clean();
       matrix.dawBitmap(0, 0, patern7_bmp, 8, 8, LED_ON);
       matrix.writeDisplay();
       delay(500);
     
       matrix.clean();
       matrix.dawBitmap(0, 0, patern8_bmp, 8, 8, LED_ON);
       matrix.writeDisplay();
       delay(500);
    }
    Also so you could understand what actually the patern_bmp[] are, they are basically the 8x8 Matrix LED mapping for the LED's.
    1 means ON, 0 means OFF, so am technically mapping right there how to LED's are going to switch ON and in what pattern.


    Here are the errors I got:
    'class Adafruit_8x8matrix' has no member named 'drawBitmap'
     
    In file included from sketch_aug01a.ino:2:
    C:\Users\user\Documents\Arduino\libraries\Adafruit_LEDBackpack/Adafruit_LEDBackpack.h:32:26: error: Adafruit_GFX.h: No such file or directory
    sketch_aug01a.ino:3:26: error: Adafruit_GTX.h: No such file or directory
    In file included from sketch_aug01a.ino:2:
    C:\Users\user\Documents\Arduino\libraries\Adafruit_LEDBackpack/Adafruit_LEDBackpack.h:94: error: expected class-name before '{' token
    C:\Users\user\Documents\Arduino\libraries\Adafruit_LEDBackpack/Adafruit_LEDBackpack.h:103: error: expected class-name before '{' token
    sketch_aug01a.ino: In function 'void loop()':
    sketch_aug01a:107: error: 'class Adafruit_8x8matrix' has no member named 'drawBitmap'
    sketch_aug01a:107: error: 'neutral_bmp' was not declared in this scope
    sketch_aug01a:112: error: 'class Adafruit_8x8matrix' has no member named 'drawBitmap'
    sketch_aug01a:117: error: 'class Adafruit_8x8matrix' has no member named 'drawBitmap'
    sketch_aug01a:122: error: 'class Adafruit_8x8matrix' has no member named 'drawBitmap'
    sketch_aug01a:127: error: 'class Adafruit_8x8matrix' has no member named 'drawBitmap'
    sketch_aug01a:132: error: 'class Adafruit_8x8matrix' has no member named 'drawBitmap'
    sketch_aug01a:137: error: 'class Adafruit_8x8matrix' has no member named 'drawBitmap'
    sketch_aug01a:142: error: 'class Adafruit_8x8matrix' has no member named 'drawBitmap'

    Now what really really confuses me is that first of all that the command drawBitmap was taken from the example of the already pre-made arduino 8x8matrix sketches.
    I have also double checked that i have included all the libraries needed, and came across a very interesting thing.
    The PROGMEM is actually a command that stores data in flash (program) memory instead of using SRAM. The PROGMEM keyword is a variable modifier, it should be used only with the datatypes defined in pgmspace.h. It tells the compiler "put this information into flash memory", instead of into SRAM, where it would normally go.
    And the PROGMEM is part of the pgmspace.h library, so that means that we need to include the library at the top your sketch #include <avr/pgmspace.h>.

    I have tried doing that and nothing happen, the weird thing is that non of the presets that came with the Adafruit code/library had that library included but they all had the command static const uint8_t PROGMEM. I do not understand why would this command work in first place if the library is not included/invoked, but it is anyway.
    Shouldn't I get an error saying that static const uint8_t PROGMEM is not valid, because the library is not included??
    And also why am i getting an error that there's no such directort/file as Adafruit_LEDBackpack or Adafruit_GTX.h when i have them clearly, if I did not I would not be able to even upload the given sketches in first place.

    Any help is really appreciated!!


  2. #2
    Junior Member Goxy's Avatar
    Join Date
    Apr 2014
    Location
    Czech Republic
    Posts
    11
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Re: Arduino

    Ok, after a lot of trial and error I finally found where the bug was.
    It seems to me that those Adafruit libraries were not correctly included on my sketch.
    In addition to downloading and installing the library onto the Arduino library directory (on Windows, that's normally C:\Users\UserName\Documents\Arduino\libraries), when you want to use that library with Arduino IDE, you must add the library for your sketch with the menu command "Sketch -> Import Library..."
    Important note: it seems that just adding #include "library.h" does not work with Arduino IDE, you absolutely need to use the menu, or just type it out correctly.

    I had written:
    #include "Adafruit_LEDBackpack.h"
    #include "Adafruit_GTX.h"


    When I really needed to just import them from the "Sketch -> Import Library..." and they would look like this:
    #include <Adafruit_LEDBackpack.h>
    #include <Adafruit_GTX.h>


    But it still leaves me with one unsolved question of how does the static const uints8_t PROGMEM work without including the #include <avr/pgmspace.h> library. If anyone knows why, I'd appreciate if they could explain it, it would really shine some light on how this pattern creating works!

Similar Threads

  1. String +DatagramPacket+ Android + Arduino
    By mani3321 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: March 19th, 2014, 07:22 AM
  2. Replies: 1
    Last Post: July 6th, 2013, 08:17 PM
  3. Java netbeans to Arduino (Serial Data)
    By philli3 in forum File I/O & Other I/O Streams
    Replies: 0
    Last Post: March 10th, 2012, 08:06 AM