Close
0%
0%

LED Matrix with Raspberry PI and Arduino Nano's

I have created a LED Matrix that is 50x36. It has 6 Arduino Nano's that each control 6 strings of 50 LEDs. Works with Jinx using Gledidtor

Public Chat
Similar projects worth following
The next stage of the project is to use a Raspberry to drive the 6 Arduino's. I plan to use the output of Glediator as the input files. I am able to see the /dev/ttyUSB0 through /dev/ttyUSB5 devices. I'm trying to write a C++ program on the Raspberry Pi to send the data. I know I'm sending data as I see the Rx/Tx lights. But the Arduino does not always do what I expect it to do.
  • 1 × Raspberry Pi
  • 6 × Arduino Nano
  • 6 × WS2812B 300LED 5V
  • 1 × Hardboard 2'x4'
  • 2 × 300 watt 5V Power supply

Enjoy this project?

Share

Discussions

Newton wrote 04/25/2018 at 01:38 point

I'm still trying to get this to work.  At this point I'm trying to get communications going that I can trust.

This is the C++ code I'm running on the Raspberry Pi.  I'm leaving the communications rate at 9600 baud.  I have also I have also used:  stty -F /dev/ttyACM0 sane.

I have tried other settings.  I have tried code C code as well.

I'm using an Arduino Uno for this test.  That is why it use the /dev/ttyACM0 instead of the /dev/ttyUSB0

#include <iostream>

#include <fstream>
using namespace std;
Int main() {
   ofstream USB;
   USB.open("/dev/ttyACM0");
   USB << "asdfasdf";
   USB.close();
   return 0;
}


This is my test script on the Arduino

char inChar = -1;

void setup() {
   Serial.begin(9600);
   pinMode(LED_BUILTIN, OUTPUT);
}
void loop() {
   while(true) {
      while(serial.available() > 0) {
      inChar = Serial.read();
   digitalWrite(LED_BUILTIN, HIGH);
   delay(1000);
   digitalWrite(LED_BUILTIN, LOW);
   Serial.write(inChar);
      }
   }
}


If I use the Arduino serial monitor, it works exactly as expected.  1 second of LED on per character sent.  Also prints the character in the serial monitor.  If I run the C++ script, is see the Rx/Tx light go, but usually does not cause the LED to lite for 8 seconds. If I run it several times, one might work.  I'm thinking that must have something to do with serial flow control.  

Does anyone have any ideas?


Also, I don't have remote access setup on my Pi yet, so I copied the code by hand.  Please excuse if I made a typo.

  Are you sure? yes | no

Newton wrote 04/25/2018 at 01:06 point

This is the Arduino code I use with Jinx! using the Glediator protocol:

It has one problem.  I had to put an extra while(serialGlediator() != 1) {} at the bottom that I just throw away.  Otherwise there random patterns that flash.  Still trying to understand why.  But it works!

// Glediator script for WS2812B LEDs
// Found at:  https://forum.pjrc.com/threads/32861-Glediator-Jinx-with-Teensy-3-2-and-WS2812b
// User mortonkopf 02-09-2016 @ 4:57 PM
// Tested with JINX!
// Set NUM_LEDS to the number of LEDS in the string your are controlling.  // Set dataline to the Arduino PIN you are going to use.
// You must install the FastLED Library.
// I have tested wint Arduino UNO R2 and R3.  Arduino Mega 2560 R3 and SainSmart (Not sure which version)
#include "FastLED.h"
#define NUM_LEDS 300             // Set the number of LEDs
const int dataline = 6;          // Arduino PIN
CRGB leds[NUM_LEDS];
void setup() {
  Serial.begin(115200);
  LEDS.addLeds<WS2812B, dataline>(leds, NUM_LEDS);
}
int serialGlediator() {
  while(!Serial.available()) {}
    return Serial.read();
}
void loop() {
  while(serialGlediator() != 1) {}
  for(int i=0; i < NUM_LEDS; i++) {
    leds[i].r = serialGlediator();
    leds[i].g = serialGlediator();
    leds[i].b = serialGlediator();
  }
  FastSPI_LED.show();
  while(serialGlediator() != 1) {}
  //delay(100);
}

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates