(TECH) RePhone with LED Matrix

Moderators: lily.li, violet, jessie, chao.zhang

catalinanesia
Pre-kindergarten
Pre-kindergarten
Posts: 35
Joined: Thu Dec 10, 2015 8:24 am

Re: (TECH) RePhone with LED Matrix

Post by catalinanesia » Sat Mar 26, 2016 4:13 am

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)
Image
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:
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!
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_AP ... edMatrix.h

Thank you! for any help

Code: Select all

/*
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();
}
}
}
}

catalinanesia
Pre-kindergarten
Pre-kindergarten
Posts: 35
Joined: Thu Dec 10, 2015 8:24 am

Re: (TECH) RePhone with LED Matrix

Post by catalinanesia » Sat Mar 26, 2016 9:56 am

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:
Image
and this is what I have on LED Matrix:
Image

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:

Code: Select all

const int buttonPin = 29;    // button pin on RePhone pad A1
If I use this in code then will output an error at compile time:

Code: Select all

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!

dbelam
Elementary-1
Elementary-1
Posts: 157
Joined: Wed Feb 03, 2016 2:59 am

Re: (TECH) RePhone with LED Matrix

Post by dbelam » Sat Mar 26, 2016 7:23 pm

>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. :)

catalinanesia
Pre-kindergarten
Pre-kindergarten
Posts: 35
Joined: Thu Dec 10, 2015 8:24 am

Re: (TECH) RePhone with LED Matrix

Post by catalinanesia » Sun Mar 27, 2016 10:50 pm

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) :oops:
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 ...
>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. :)
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

dbelam
Elementary-1
Elementary-1
Posts: 157
Joined: Wed Feb 03, 2016 2:59 am

Re: (TECH) RePhone with LED Matrix

Post by dbelam » Mon Mar 28, 2016 5:57 am

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 http://www.farnell.com/datasheets/2012663.pdf)

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

catalinanesia
Pre-kindergarten
Pre-kindergarten
Posts: 35
Joined: Thu Dec 10, 2015 8:24 am

Re: (TECH) RePhone with LED Matrix

Post by catalinanesia » Mon Mar 28, 2016 10:37 am

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)
Image
and this is what I get actually on the matrix:
Image
Image
The matrix should show the full "smile" face but instead is displayng only half of it correct and the bottom half is always scrambled :(

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!

dbelam
Elementary-1
Elementary-1
Posts: 157
Joined: Wed Feb 03, 2016 2:59 am

Re: (TECH) RePhone with LED Matrix

Post by dbelam » Mon Mar 28, 2016 6:49 pm

Yepp, the led matrix MUST be ok: "Operating voltage: 4.5V~5.5V" from the dathasheet (https://www.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.

catalinanesia
Pre-kindergarten
Pre-kindergarten
Posts: 35
Joined: Thu Dec 10, 2015 8:24 am

Re: (TECH) RePhone with LED Matrix

Post by catalinanesia » Mon Mar 28, 2016 7:31 pm

Hi Bela,

Here is the code:

Code: Select all

/*
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;
  }
}
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!

Post Reply