Trying to communicate with Denon MediaPlayer

Hello Everyone,

I’m quite new to the Arduino. A few years ago I did a very simple project where I was using an Arduino to convert continuous contacts to momentary contacts.

Now I’m trying to do something completely different. I have 3 Denon DN-500R professional mediaplayers.
These devices have a RS-232 port that can be used to control and “read” every player.
What I want to do is to get the remaining playbacktime for each player. I’m using a Mega to do this, because it has 4 serial ports.
To start the easy way, I’ve used a code snippet that I’ve found here in a tutorial. This example is working, but. I’m reading serial data from Serial1 and send it to Serial, so I can see it in the monitor.
So far, so good. Now I want to send data to Serial when it has changed. This is to avoid to have a lot of strings that are all the same. I only want to see them. For this, I’ve adapted the code to send data to Serial only when it has changed. But I can’t get this working. In the serial monitor I keep seeing identical lines.

Can somebody have a look at my code to help me find my error ?
I use to program in other languages, so I’m not a complete newbie, I just don’t have enough knowledge of the Arduino Language.

This is my code :



// DenonDisplayer v1

const byte numChars = 32;
char receivedChars[numChars]; // an array to store the received data
char PrevChars[numChars];
boolean newData = false;

void setup() {

void loop() {

void recvWithEndMarker() {
static byte ndx = 0;
char endMarker = ‘\r’;
char rc;

while (Serial1.available() > 0 && newData == false) {
rc =;

if (rc != endMarker) {
receivedChars[ndx] = rc;
if (ndx >= numChars) {
ndx = numChars - 1;
else {
receivedChars[ndx] = ‘\0’; // terminate the string
ndx = 0;
newData = true;

void showNewData() {
if (newData == true) {
if (PrevChars != receivedChars) {
Serial.print("This just in … ");
PrevChars == receivedChars;
newData = false;

Who can put me on the right track ?



You cannot compare arrays this way:

if (PrevChars != receivedChars) {


When using Cstrings you must use strcmp() to compare values rather than ==


PS ... When posting code please use the code button </>

so your code looks like this

and is easy to copy to a text editor See How to use the Forum