Sparkfun Redboard serial randomly nulls

Hi, I'm currently trying to connect both my processing and arduino sketch together using the serial. It works for a short time, then it will stop receiving any inputs, and only send null on the receiver.

The code below uses some dotstar code, just ignore it

#include <Adafruit_DotStar.h>
#include <SPI.h>

#define DATAPIN    4
#define CLOCKPIN   5

Adafruit_DotStar strip(30, DATAPIN, CLOCKPIN, DOTSTAR_BRG);
uint32_t magenta = strip.Color(255, 0, 255);
uint32_t green = strip.Color(0, 255, 0);
uint32_t red = strip.Color(255, 0, 0);
char val;
bool trigger = false;

void setup() {
  Serial.begin(9600);
  pinMode(LED_BUILTIN, OUTPUT);
  // establishContact();
  strip.begin();
  strip.show(); 
  establishContact();  // send a byte to establish contact until receiver responds 
}

void loop() {
  int val0 = -1;
  int val1 = -1;
  int val2 = -1;
  int val3 = -1;
  bool s = trigger;
  if (Serial.available() > 0) { // If data is available to read,
    val = Serial.read(); // read it and store it in val
    if(val == 'p') {
      trigger = true;
    }
    if(val == 'b') {
      trigger = false;
    }
  } 
    else {
    delay(50);
  }
  if (s) {
    strip.fill(magenta, 0, 30);
    strip.show();
  }
  else {
    strip.fill(green, 0, 30);
    strip.show();
  }
  Serial.println("" + String(val0) + " " + val1 + " " + val2 + " " + val3);
  delay(200);
}
void establishContact() {
  while (Serial.available() <= 0) {
  Serial.println("A");   // send a capital A
  delay(300);
  }
}

upload a copy of the serial monitor output as text (not an image)
this may give some idea of where the program fails
does it always fail at the same point?
give more details of the hardware and a schematic of the wiring?

It will be a string of "-1 -1 -1 -1" (which is correct), and then eventually it stops sending them whatsoever, just a bunch of nulls

It seems to slow down after a bit, and then after I send another command, it will crash

It's a sparkfun redboard, here's the product page link: SparkFun RedBoard - Programmed with Arduino - DEV-13975 - SparkFun Electronics

The wiring is just a basic dotstar board, looks like this (the example uses a different controller)
image

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.