Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RDM channel size from 3 to 4 #28

Open
ghost opened this issue May 18, 2020 · 3 comments
Open

RDM channel size from 3 to 4 #28

ghost opened this issue May 18, 2020 · 3 comments

Comments

@ghost
Copy link

ghost commented May 18, 2020

Anyone knowing how to increase the number of channels from 3 to 4. The example have 3 channels, RGB for LED's, I would like to add an additional channel. I can't find where to change 3 to 4, anyone who knows where to change it?

@peternewman
Copy link
Contributor

Hi @Jabadabado ,

Setting the 3 to a 4 here will change the number of channels it says it needs via RDM:

From a PWM output point of view, it's being done here:

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.
// color: #203050 * 2
#define RedDefaultLevel 0x20 * 2
#define GreenDefaultLevel 0x30 * 2
#define BlueDefaultLevel 0x50 * 2
// define the RGB output color
void rgb(byte r, byte g, byte b)
{
analogWrite(RedPin, r);
analogWrite(GreenPin, g);
analogWrite(BluePin, b);
} // rgb()

And:
// set default values to dark red
// this color will be shown when no signal is present for the first 5 seconds.
DMXSerial2.write(start + 0, 30);
DMXSerial2.write(start + 1, 0);
DMXSerial2.write(start + 2, 0);
// enable pwm outputs
pinMode(RedPin, OUTPUT); // sets the digital pin as output
pinMode(GreenPin, OUTPUT);
pinMode(BluePin, OUTPUT);

And
if (now % 1000 < 500) {
rgb(200, 200, 200);
} else {
rgb(0, 0, 0);
} // if
} else if (lastPacket < 30000) {
// read recent DMX values and set pwm levels
analogWrite(RedPin, DMXSerial2.readRelative(0));
analogWrite(GreenPin, DMXSerial2.readRelative(1));
analogWrite(BluePin, DMXSerial2.readRelative(2));
} else {
#if defined(SERIAL_DEBUG)
Serial.println("no signal since 30 secs.");
#endif
// Show default color, when no data was received since 30 seconds or more.
analogWrite(RedPin, RedDefaultLevel);
analogWrite(GreenPin, GreenDefaultLevel);
analogWrite(BluePin, BlueDefaultLevel);

@wad77
Copy link

wad77 commented Jan 18, 2024

Hello, I'm a complete newbie to Arduino. Please write how to make 6 PWM channels on Arduino UNO. I beg you very much. I don't know how to edit code. THANK YOU VERY MUCH!

@mathertel
Copy link
Owner

Hello, I'm a complete newbie to Arduino. Please write how to make 6 PWM channels on Arduino UNO. I beg you very much. I don't know how to edit code. THANK YOU VERY MUCH!

The best you can do is learning programming and take the ownership of what you need and have done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants