Hello! I am trying to use the Sparkfun DMX shield with my arduino mega 2560 board. I am trying to get the example code to work. However, the example code is for ESP32 which I don't have. From my understanding the shield should work with a standard Arduino too. I am struggling with editing the code to work with Arduino. I want to use the serial1 (ports 18 and 19) for communication between arduino and the DMX shield. There is something wrong with line 28.
Here is the schematic of my connections etc.
Here is the code I am working with, which I need help with:
/*
Writes DMX data to channel 1
By: Dryw Wade
SparkFun Electronics
Date: 10/3/2023
License: GNU. See license file for more information but you can
basically do whatever you want with this code.
This example runs two servos and a number of LED's off of 5 DMX channels
Feel like supporting open source hardware?
Buy a board from SparkFun! https://www.sparkfun.com/products/15110
Hardware Connections:
Connect a Thing Plus board to the SparkFun DMX Shield, and connect a DMX XLR-3
cable between the shield and another device that outputs DMX data. You can use
a second board and shield running Example 2!
*/
// Inlcude DMX library
#include <SparkFunDMX.h>
// Create DMX object
SparkFunDMX dmx;
// Create serial port to be used for DMX interface. Exact implementation depends
// on platform, this example is for the ESP32
HardwareSerial dmxSerial(2);
// Enable pin for DMX shield (Free pin on Thing Plus or Feather pinout)
uint8_t enPin = 21;
// Number of DMX channels, can be up tp 512
uint16_t numChannels = 100;
// Create a counter as example data
uint8_t counter = 0;
void setup()
{
Serial.begin(115200);
Serial.println("SparkFun DMX Example 1 - Output");
// Begin DMX serial port
dmxSerial.begin(DMX_BAUD, DMX_FORMAT);
// Begin DMX driver
dmx.begin(dmxSerial, enPin, numChannels);
// Set communicaiton direction, which can be changed on the fly as needed
dmx.setComDir(DMX_WRITE_DIR);
Serial.println("DMX initialized!");
}
void loop()
{
// Write counter to channel 1
dmx.writeByte(counter, 1);
// Once all data has been written, update() must be called to actually send it
dmx.update();
Serial.print("DMX: sent value to channel 1: ");
Serial.println(counter);
// Increment counter (overflows back to 0 after 255)
counter++;
// Slow down communication for this example
delay(100);
}
Trying to verify the code, i get the following error
C:\Users\5600X\AppData\Local\Temp.arduinoIDE-unsaved20231114-10440-3358x2.k6mkj\Example1-DMXOutput\Example1-DMXOutput.ino:28:27: error: no matching function for call to 'HardwareSerial::HardwareSerial(int)'
HardwareSerial dmxSerial(2);
^
In file included from C:\Users\5600X\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino/Arduino.h:233:0,
from C:\Users\5600X\AppData\Local\Temp\arduino\sketches\B60D227A5F3B3AC660AB77868C086975\sketch\Example1-DMXOutput.ino.cpp:1:
C:\Users\5600X\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino/HardwareSerial.h:117:12: note: candidate: HardwareSerial::HardwareSerial(volatile uint8_t*, volatile uint8_t*, volatile uint8_t*, volatile uint8_t*, volatile uint8_t*, volatile uint8_t*)
inline HardwareSerial(
^~~~~~~~~~~~~~
C:\Users\5600X\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino/HardwareSerial.h:117:12: note: candidate expects 6 arguments, 1 provided
C:\Users\5600X\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino/HardwareSerial.h:93:7: note: candidate: constexpr HardwareSerial::HardwareSerial(const HardwareSerial&)
class HardwareSerial : public Stream
^~~~~~~~~~~~~~
C:\Users\5600X\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino/HardwareSerial.h:93:7: note: no known conversion for argument 1 from 'int' to 'const HardwareSerial&'
C:\Users\5600X\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino/HardwareSerial.h:93:7: note: candidate: constexpr HardwareSerial::HardwareSerial(HardwareSerial&&)
C:\Users\5600X\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino/HardwareSerial.h:93:7: note: no known conversion for argument 1 from 'int' to 'HardwareSerial&&'
exit status 1
Compilation error: no matching function for call to 'HardwareSerial::HardwareSerial(int)'