Store › Forums › RGB Matrix Backpack › General Discussion › Fetching data to RGB backpack
- This topic has 5 replies, 3 voices, and was last updated 8 years ago by simon_schvartzman.
-
AuthorPosts
-
October 23, 2016 at 1:10 pm #8517simon_schvartzmanParticipant
Hi, I would like to know the easiest way to dynamically fetch data to the RGB backpack to be displayed on the matrix.
In other words I would like to have another Arduino sending data to the backpack.
Looking forward for help!
October 24, 2016 at 7:25 am #8521MichaelKeymasterThe easiest way to communicate is with a serial connection. The board has a 6-pin serial header, so just learn about Arduino serial communication and you are good to go.
October 24, 2016 at 10:53 am #8522simon_schvartzmanParticipantThanks Michael, that’s very useful.
Regards
October 25, 2016 at 6:25 pm #8525simon_schvartzmanParticipantHi, for those who need help with this subject
CODE FOR THE UNO SENDING DATA TO THE BACKPACK
/* Simple sketch to demostrate how to send data from an Arduino Uno to the nootropic RGB Matrix backpack This is the code on the Uno Side The program will do the following: - send a command (Blue Square) - wait 5 secs - send a command to clear the display (Clear) Connections UNO BackPack FTDI Connector Pin 10 (Rx) Pin # 2 (near the +5V terminal) Pin 11 (Tx) Pin # 3 Ground Pin # 6 (right most pin near the Power Jack) */ #include <SoftwareSerial.h> // we will use a soft serial #define Serial_baud_rate 9600 // Comm speed between the boards #define serial_Rxd 10 // Rx to be connected to Tx on the backpack #define serial_Txd 11 // Tx to be connected to Rx on the backpack SoftwareSerial BP_serial(serial_Rxd, serial_Txd); //Define the soft serial String inputString = ""; // a string to hold incoming data void setup() { Serial.begin (9600); //open main Serial port Serial.println ("start"); BP_serial.begin(Serial_baud_rate); // Open the serial port to connect to the backpack } void loop() { BP_serial.print ("Blue Square"); //Backpack will display a Blue Square BP_serial.print (char(10)); //line has to be terminated with line feed (/n) delay (7000); BP_serial.print ("Clear"); //Backpack will clear the matrix BP_serial.print (char(10)); delay (2000); SerialRead (); //Read feedback (echo) from backpack } /* Read the Serial connection */ void SerialRead() { while (BP_serial.available()) { // get the new byte: char inChar = (char)BP_serial.read(); // add it to the inputString: inputString += inChar; if (inChar == '\n') // end of line received { Serial.println (inputString); inputString = ""; //clean up for next reading } } }
CODE FOR THE BACKPACK
// Simple sketch (BackPack) to show how to receive commands from an Arduino Uno // with the nootropic RGB BackPack. // Before connecting to the Uno you can test the program by sending // the commands using the IDE Serial Monitor. Just remember to set it up // // Writen by Simon Schvartzman // based on: // testshapes demo for Adafruit RGBmatrixPanel library. // Demonstrates the drawing abilities of the RGBmatrixPanel library. // For 32x32 RGB LED matrix: // http://www.adafruit.com/products/607 // Written by Limor Fried/Ladyada & Phil Burgess/PaintYourDragon // for Adafruit Industries. // BSD license, all text above must be included in any redistribution. // Connections // UNO BackPack FTDI Connector // Pin 10 (Rx) Pin # 2 (near the +5V terminal) // Pin 11 (Tx) Pin # 3 // Ground Pin # 6 (right most pin near the Power Jack) #include <Adafruit_GFX.h> // Core graphics library #include <RGBmatrixPanel.h> // Hardware-specific library #define CLK 8 // MUST be on PORTB! (Use pin 11 on Mega) #define OE 9 #define LAT 10 #define A A0 #define B A1 #define C A2 #define D A3 RGBmatrixPanel matrix(A, B, C, D, CLK, LAT, OE, false); String inputString = ""; // a string to hold incoming data boolean stringComplete = false; // flag to mark the string is complete void setup() { Serial.begin (9600); matrix.begin(); } void loop() { //Serial.println ("Hello World"); // print the string when a newline arrives: if (stringComplete == true) { Serial.println(inputString); //read the command and act accordingly if (inputString == "Blue Square") { BlueSquare (); } if (inputString == "Clear") { clearMatrix (); } // clear the string: inputString = ""; stringComplete = false; } delay (5000); //inputString = ""; //serialRead(); } void BlueSquare () { //fill in a rectangle in blue for (int i = 10; i < 22; i = i + 1) { for (int j = 10; j < 22; j = j + 1) { matrix.drawPixel(i, j, matrix.Color333(0, 0, 7)); delay (15); } } } void clearMatrix() { // fill the screen with 'black' matrix.fillScreen(matrix.Color333(0, 0, 0)); } /* SerialEvent occurs whenever a new data comes in the hardware serial RX. This routine is run between each time loop() runs, so using delay inside loop can delay response. Multiple bytes of data may be available. */ void serialEvent() { while (Serial.available()) { // get the new byte: char inChar = (char)Serial.read(); if (inChar == '\n') { // if the incoming character is a newline, set a flag // so the main loop can do something about it: stringComplete = true; } else { // add it to the inputString: inputString += inChar; } } }
November 1, 2016 at 12:31 pm #8548mdmParticipantThis technique is working pretty well for me! Next step is to connect to a Pi. While I plan to measure voltage first, can you tell us off the top of your head whether the serial pins are 3.3V or 5V?
November 1, 2016 at 12:45 pm #8549simon_schvartzmanParticipantDefinitely 5 V.
Good luck with your project.
-
AuthorPosts
- You must be logged in to reply to this topic.