mathertel / DMXSerial

An Arduino library for sending and receiving DMX packets.
BSD 3-Clause "New" or "Revised" License
328 stars 78 forks source link

Receiving problem #46

Closed ozyeng closed 4 years ago

ozyeng commented 4 years ago

I'm trying to light up red, green and blue leds using two arduinos

I can send the proper DMX signal but i cant receive.

Here is the sender arduino's code;

#include <DMXSerial.h>

void setup() {

  DMXSerial.init(DMXController,2);
  DMXSerial.maxChannel(3);

}

void loop() {
  DMXSerial.write(1, 255);
  DMXSerial.write(2, 0);
  DMXSerial.write(3, 255);  

}

and the receiver arduino;

#include <DMXSerial.h>

const int RedPin =    9;  // PWM output pin for Red Light.
const int GreenPin =  6;  // PWM output pin for Green Light.
const int BluePin =   5;  // PWM output pin for Blue Light.

void setup() {

  DMXSerial.init(DMXReceiver,2);
  DMXSerial.maxChannel(3);

  pinMode(RedPin,   OUTPUT); // sets the digital pin as output
  pinMode(GreenPin, OUTPUT);
  pinMode(BluePin,  OUTPUT); 
}

void loop() {
  unsigned long lastPacket = DMXSerial.noDataSince();  

 if (lastPacket < 1000) {   
      analogWrite(RedPin, DMXSerial.read(1));
      analogWrite(GreenPin, DMXSerial.read(2));
      analogWrite(BluePin, DMXSerial.read(3));   
    }

else{
  analogWrite(RedPin,255);
    }

}

Here is my proteus design;

1

Is there a problem with my code or is this a simulation problem ?

mathertel commented 4 years ago

Maybe the simulating doesn't handle the interrupt driven output correctly because I cannot see the break in the oscilloscope. I can't see a wiring topic here you just try in real hardware.