(TECH) RePhone with LED Matrix

Hi everyone,
Will RePhone GSM+BLE be able to drive this LED Matrix https://www.adafruit.com/products/870 with backpack from Adafruit? if yes do I need to do something special under Arduino IDE other than including the Adafruit library for that Matrix? if not what options I have to drive a LED Matrix with it?
Thank you for guidance!

Regards,
Catalin

Give it power, connect and it should work - I don’t see why not. Just go through the code for config (I2C address) and other stuff.

Thanks! dbelam
I am a newbie in all the aspects (electronics, Arduino and programming) but what do you mean by this:
“go through the code for config (I2C address)”

Regards,
Cat

Oh, thank you for telling me your knowledge.
I2C devices have a somewhat unique address, and your module’s address can be changed with jumpers - so check the arduino code and the module’s documentation, and make the 2 address match. Oh, and the “write” and “read” address is different by 1 bit!

Thanks! dbelam for the advice,
Therefore this wiring will work: Can I add 2 pushbuttons on Int1 (pin 4) and Int2 (pin 5)? INT stands for what?

Add the 2 power pins too (the bare minimum is to connect the 2 GND pins, but you probably want to give power from rephone, so connect the vcc-s too)
and INT stands for Interrupt - that means it can signal an event, so the module will know when something happened. Don’t add buttons there please :slight_smile:

Clear enough for the LED matrix wiring, but what about the buttons? likely I have the GSM breakout board that I can connect with the ribbon to the RePhone and add some buttons. Under Wiki for GSM Breakout it states: Up to 16 General Purpose Inputs/outputs (GPIOs) - unfortunately I am not sure where to locate those on the diagram for Arduino on the Wiki page. Are the idle GPIOs in GREEN (D2,D3,D4,D6,D7,D8 and D9) the connection points for push buttons?
Here is what I have updated according to your previous instructions:

Thanks for helping!

Hi,
If you check the button by read pin value, all the digital pin can be used.
But if you check the button by interrupt, pin INT1/E1/GPIO18, INT2/E2/GPIO13, A2/GPIO1, A3/GPIO2 can be used.

You have to decide what to give up: almost all GPIO pins are used for something - if you want to just use the LED matrix (for example in Arduino) then choose anything (but the i2c pins).
SPI pins (D2, D3, D4) can be a good choice, and since you said you are not a pro, polling (instead of using interrupts) will be enough.

Thank you both,
I would like to eliminate the GSM Breakout and use the RePhone board only since it has SCL and SDA to drive the LED Matrix and INT1 and INT2 already available to hook up 2 buttons.
Since “dbelam” strongly advised not to use (interrupts) them (probably because my lack of knowledge) I have no choice but to use the GSM Breakout to hook up the buttons on the locations you both advised.

Regards,
Cat

Why the LED Matrix does not lit up?
I have the below diagram wired up but the LED Matrix is not active at all (no blink no nothing, never lit up).
The dashed light Blue (SDA on B5) and Orange (SCL on B6) lines represents my second try when I connected the LED Matrix on the GSM Breakout and not directly on the GSM-BLE module (I do prefer to use them on the GSM-BLE module and not on the breakout)

I am using Arduino IDE and this are the included library’s and code (below)
#include <TinyWireM.h>
#include “Adafruit_LEDBackpack.h”
#include “Adafruit_GFX.h”

@dbelam
you told me this previously:

what are you saying is related with the I2C library? - #include <TinyWireM.h> (this is written by Adafruit for Trinket and Gemma modules specially)
I do have all this working on Adafruit Flora with the below code but I want to port it on the RePhone with Arduino.
If the I2C library is the issue, then will the LLedMatrix.h written by Seeed for their Xsadow LED work?
https://github.com/WayenWeng/RePhone_API_for_Arduino/blob/master/LLedMatrix.h

Thank you! for any help

[code]/*
This example code is in the public domain.

http://arduino.cc/en/Tutorial/ButtonStateChange

*/

#include <TinyWireM.h>
#include “Adafruit_LEDBackpack.h”
#include “Adafruit_GFX.h”

const int buttonPin = D3; // button pin set on GSM Breakout pad A1

Adafruit_8x8matrix matrix = Adafruit_8x8matrix();

// Variables will change:
int buttonPushCounter = 0; // counter for the number of button presses
int buttonState = 0; // current state of the button
int lastButtonState = 0; // previous state of the button

void setup() {
// initialize the button pin as a input:
pinMode(buttonPin, INPUT);
matrix.begin(0x70); // pass in the address
}

static const uint8_t PROGMEM // X and square bitmaps
hearth_bmp[] =
{ B00111100,
B01000010,
B10100101,
B10000001,
B10100101,
B10011001,
B01000010,
B00111100 },
smile_bmp[] =
{ B00100100,
B01011010,
B10011001,
B10000001,
B10000001,
B01000010,
B00100100,
B00011000 },
flower_bmp[] =
{ B11000011,
B10100101,
B01100110,
B00011000,
B01111011,
B10101110,
B11001100,
B00001000 };

void loop() {
// read the pushbutton input pin:
buttonState = digitalRead(buttonPin);

// compare the buttonState to its previous state
if (buttonState != lastButtonState) {
// if the state has changed, increment the counter
if (buttonState == HIGH && lastButtonState == LOW) {
// if the current state is HIGH then the button
// went from off to on:
buttonPushCounter++;
} else {
// if the current state is LOW then the button
// went from on to off:
}
}
// save the current state as the last state,
//for next time through the loop
lastButtonState = buttonState;

// turns on the LED every four button pushes by
// checking the modulo of the button push counter.
// the modulo function gives you the remainder of
// the division of two numbers:
if (buttonPushCounter % 4 == 0) {
matrix.clear();
matrix.drawBitmap(0, 0, hearth_bmp, 8, 8, LED_ON);
matrix.writeDisplay();
buttonState = HIGH;

if (buttonPushCounter % 1 == 0){
matrix.clear();
matrix.drawBitmap(0, 0, smile_bmp, 8, 8, LED_ON);
matrix.writeDisplay();
buttonState = HIGH;

if (buttonPushCounter % 2 == 0){
matrix.clear();
matrix.drawBitmap(0, 0, flower_bmp, 8, 8, LED_ON);
matrix.writeDisplay();
buttonState = HIGH;
} else {
matrix.clear();
}
}
}
}[/code]

Well …
I had some imperfect connections and I remade the wiring (DO NOT USE THE PREVIOUS DIAGRAM, the Vcc of the LED Matrix is wired directly to the battery 3.7 V bigger than the recommended 2.8 V for RePhone)
Here the working diagram:

and this is what I have on LED Matrix:

I am expecting to have a clean image on the LED matrix but I do not, why? code or hardware?
The button is on breakout A1 (D3 on the Arduino pin out breakout board wiki diagram), do I call it pin #29 in the code as per the cross reference pin file?
like this:

const int buttonPin = 29;    // button pin on RePhone pad A1

If I use this in code then will output an error at compile time:

const int buttonPin = D3;    // button pin on RePhone pad A1

and this is the error message:
error: ‘D3’ was not declared in this scope
If I press the button nothing happens … (it should change the displayed pictogram)

Please advice
ThankS!

I am expecting to have a clean image on the LED matrix but I do not, why? code or hardware?

MAYBE connecting directly to the battery fried it a little (I’ll have to check the circuit if it tolerates up to 4.2V)

And

error: ‘D3’ was not declared in this scope
is like you forgot to import the definitions of the pins - try to set up the rephone’s Arduino IDE again. :slight_smile:

Thanks! dbelam
Well probably something is fried since I’ve connected the LED Matrix directly to 3 x 1.5v AAA batt. pack (4.5v) :blush:
and the SDA & SLC from the matrix to the GSM+BLE pin 1 & 2 and also to the GSM Breakout B5 and B6. (stupid me)
Now if I connect the SDA & SLC to GSM Breakout the matrix is not lit at all; If I connect them on the RePhone GSM+BLE board then half of the LED Matrix displays some random lit dots and exactly half of it works properly displaying half of the pattern I want …

To solve this thanks to alexandru.m.ghe reply on the “Access the GPIO Pins based on Different IDEs” I have replaced the
“D3” in code with “3” and yupiii it worked as expected.

Regards,
Catalin

Could you please send, how did you exactly connected the boards and the battery pack?

Just because the led matrix board must have survived your 3x AA batteries: it has a power regulator and it must work up to 6V! (I checked the circuit, datasheet of the regulator here farnell.com/datasheets/2012663.pdf)

Maybe you forgot to add a proper common ground, therefore the communication fails - hopefully.

Szia,
I am using this LED Matrix with backpack from Adafruit
https://www.adafruit.com/products/871
and this is how I wired it with the 3xAAA battery pack:
LED /…/Battery
VCC -> positive (red wire)
GND -> negative (black wire)
LED /…/RePhone GSM+BLE
SDA -> pin 1 (SDA)
SCL -> pin 2 (SCL)

The LED Matrix is fully functional, nothing is burned because when I have it connected to RePhone and I turn it off for a split second all the LED’s on the matrix are turning on (yellow), so it is functional.
I am afraid that RePhone got damaged since my pictogram’s are not drawn fully on the LED Matrix (only half side of them).

This is what I’m expecting to see for every button press (the pictogram will change)

and this is what I get actually on the matrix:


The matrix should show the full “smile” face but instead is displayng only half of it correct and the bottom half is always scrambled :frowning:

When I did this with Adafruit Flora or Gemma instead of RePhone I used this library (#include <TinyWireM.h>) but now with RePhone I can not because it gives this error message:
C:\Users\Catalin\Documents\Arduino\libraries\TinyWireM_master\USI_TWI_Master.cpp:23:24: fatal error: util/delay.h: No such file or directory
#include <util/delay.h>
so I am using #include <Wire.h> instead and I have no error at compile but maybe the library is the matrix display issue,
any suggestions?

Thanks!

Yepp, the led matrix MUST be ok: “Operating voltage: 4.5V~5.5V” from the dathasheet (adafruit.com/datasheets/ht16K33v110.pdf)

The faces are somewhat OK, so the rephone DOES work, but the question is: why does it mess up?

Can you add some delay inbetween sending the command data? If not, please send your whole code - maybe a little pause must be inserted.

Hi Bela,

Here is the code:

[code]/*
This example code is in the public domain.

http://arduino.cc/en/Tutorial/ButtonStateChange

*/
//#include <TinyWireM.h>
#include <Wire.h>
#include “Adafruit_LEDBackpack.h”
#include “Adafruit_GFX.h”

const int button1Pin = 3; // button pin on RePhone pad A1
const int button2Pin = 4; // button pin on RePhone pad E2
Adafruit_8x8matrix matrix = Adafruit_8x8matrix();

// Variables will change:
int button1PushCounter = 0; // counter for the number of button1 presses
int button1State = 0; // current state of the button1
int lastButton1State = 0; // previous state of the button1

int button2PushCounter = 0; // counter for the number of button2 presses
int button2State = 0; // current state of the button2
int lastButton2State = 0; // previous state of the button2

void setup() {
// initialize the button pin as a input:
pinMode(button1Pin, INPUT);
pinMode(button2Pin, INPUT);
matrix.begin(0x70); // pass in the address
}

static const uint8_t PROGMEM // X and square bitmaps
smile_bmp[] =
{ B00111100,
B01000010,
B10100101,
B10000001,
B10100101,
B10011001,
B01000010,
B00111100
},
hearth_bmp[] =
{ B00100100,
B01011010,
B10011001,
B10000001,
B10000001,
B01000010,
B00100100,
B00011000
},
flower_bmp[] =
{ B11000011,
B10100101,
B01100110,
B00011000,
B01111011,
B10101110,
B11001100,
B00001000
};

void loop() {
// read the pushbutton input pin:
button1State = digitalRead(button1Pin);
button2State = digitalRead(button2Pin);
// compare the buttonState to its previous state
if (button1State != lastButton1State) {
// if the state has changed, increment the counter
if (button1State == HIGH && lastButton1State == LOW) {
// if the current state is HIGH then the button
// went from off to on:
button1PushCounter++;
} else {
// if the current state is LOW then the button
// went from on to off:
}
}
// save the current state as the last state,
//for next time through the loop
lastButton1State = button1State;

// turns on the LED every four button pushes by
// checking the modulo of the button push counter.
// the modulo function gives you the remainder of
// the division of two numbers:
switch (button1PushCounter % 3)
{
case 0:
matrix.clear();
matrix.drawBitmap(0, 0, hearth_bmp, 8, 8, LED_ON);
matrix.writeDisplay();
button1State = HIGH;
break;
case 1:
matrix.clear();
matrix.drawBitmap(0, 0, smile_bmp, 8, 8, LED_ON);
matrix.writeDisplay();
button1State = HIGH;
break;
case 2:
matrix.clear();
matrix.drawBitmap(0, 0, flower_bmp, 8, 8, LED_ON);
matrix.writeDisplay();
button1State = HIGH;
}

if (button2State != lastButton2State) {
// if the state has changed, increment the counter
if (button2State == HIGH && lastButton2State == LOW) {
// if the current state is HIGH then the button
// went from off to on:
button2PushCounter++;
} else {
// if the current state is LOW then the button
// went from on to off:
}
}
// save the current state as the last state,
//for next time through the loop
lastButton2State = button2State;

// turns on the LED every four button pushes by
// checking the modulo of the button push counter.
// the modulo function gives you the remainder of
// the division of two numbers:
switch (button2PushCounter % 3)
{
case 0:
matrix.clear();
matrix.drawBitmap(0, 0, flower_bmp, 8, 8, LED_ON);
matrix.writeDisplay();
button1State = HIGH;
break;
case 1:
matrix.clear();
matrix.drawBitmap(0, 0, smile_bmp, 8, 8, LED_ON);
matrix.writeDisplay();
button1State = HIGH;
break;
case 2:
matrix.clear();
matrix.drawBitmap(0, 0, hearth_bmp, 8, 8, LED_ON);
matrix.writeDisplay();
button1State = HIGH;
}
}
[/code]

And here is what I am trying to achieve:
I have three pictogram’s: flower, smile and hearth. Every time the button 1 is pressed will display a next pictogram scrolling trough them on every press from Smile to Flower to Hearth and repeat again.
When the button 2 is pressed it will display the pictogram on the reverse direction. I know the code is not perfect but on Flora or Gemma I have the pictogram’s displayed fully and correctly therefore I am thinking the issue is with the libraries;
Wire.h on RePhone vs the TinyWireM.h on Flora that gives me an error on RePhone.
Thanks!