Trying to use RGB with an Industruino

I have a plc with stack lights. I'm trying to use an industruino to output into an RGB Green yellow and red. Depending on what the output of the plc is doing. Bascially mimicing stack lights. I'm having trouble with the code I cant seem to find a lot of good information on the industrino. I don't believe my code is where it needs to be at either. I know it can be done i'm just not fimilar with the code for these units. I posted the code below, but I feel that something is still missing. Basically if a output turns on from the plc it is inputed into the arduino and than sends out a signal for the RGB to light up that color. the board itself industrun board is a d21g

#include <Indio.h>

#include<Wire.h>

 

int Chn1 = 1;

int Chn2 = 2;

int redIn = 6;

int greenIn = 7;

int yellowIn = 8;

int runIn = 5;

 

void setup () {                  // put your setup code here, to run once:

  Indio.analogWriteMode(Chn1, V10);    // LED STRIP

  Indio.analogWriteMode(Chn2, V10);   // LED Strip

  Indio.digitalMode(redIn, INPUT);  //LED Strip

  Indio.digitalMode(greenIn, INPUT);  // Green input signal

  Indio.digitalMode(yellowIn, INPUT); // Yellow input signal

  Indio.digitalMode(runIn, INPUT);    //Red input signal

 

}

 

void loop() {

 

  //  redIn = digitalRead(2, HIGH));

  // greenIn = digitalRead(3, HIGH);

  // yellowIn = digitalRead(4, HIGH);

 

  if (Indio.digitalRead(redIn));

  {

 

    Indio.analogWrite(Chn1, 10, false);

    Indio.analogWrite(Chn2, 0, false);

 

  }

 

 

  if (Indio.digitalRead(greenIn));

  {

    Indio.analogWrite(Chn1, 0,false);

    Indio.analogWrite(Chn2, 10, false);

  }

 

 

  if (Indio.digitalRead(yellowIn));

  {

    Indio.analogWrite(Chn1, 10,false);

    Indio.analogWrite(Chn2, 10,false);

  }

 delay (5000);

}

 

 

Brett Bloomberg
Brett Bloomberg
14
| 0 0 0
Asked on 7/21/23, 7:59 PM
0
vote
402 Views

Hi Brett,

Why not use DMX512 protocol for your ligths control ? It is quite a simple RS485 network, and it even has a library that seems to work with the D21G. For example : https://tigoe.github.io/DMX-Examples/arduinodmx.html

Hope this helps

Didier, DG2R

Didier DORGUIN
Didier DORGUIN
172
| 4 1 3
Answered on 3/29/24, 7:48 AM
0
vote

You have some details in the code, let review the bold items :

  if (Indio.digitalRead(redIn));

  {

   Indio.analogWrite(Chn1, 10, false);

   Indio.analogWrite(Chn2, 0, false);

  }

First, the if statement watch a logical conditional, in some cases the way you use works, but is better use the conditional, second, you use a termination line code (;) in the if statement. For the Write output, is very best use numbers 1 or 2 for the outputs the industruino Indio only have 2 aout, so is very complicate get lost.

The if statement was most complete as:

  if (Indio.digitalRead(redIn)==1){    //Using == as "logical equal to", so if the redIn is 1 (or active), do some

   Indio.analogWrite(1, 10, false); //change the channnel number to correct with the library

   Indio.analogWrite(2, 0, false);

  }

For helping you, i change a little bit your code:

#include <Indio.h>

#include<Wire.h>

#define AOUT_CH1  1

#define AOUT_CH2  2

#define REDIN  6

#define GREENIN 7

#define YELLOWIN  8

#define RUNIN 5

 

void setup () {                  // put your setup code here, to run once:

  Indio.analogWriteMode(AOUT_CH1, V10);    // LED STRIP

  Indio.analogWriteMode(AOUT_CH2, V10);   // LED Strip

  Indio.digitalMode(REDIN, INPUT);  //Red input signal

  Indio.digitalMode(GREENIN, INPUT);  // Green input signal

  Indio.digitalMode(YELLOWIN, INPUT); // Yellow input signal

  Indio.digitalMode(RUNIN, INPUT);    //LED Strip (i think with this you enable the stripe)

}

void loop() {

  if (Indio.digitalRead(REDIN)==1)

  {

    Indio.analogWrite(AOUT_CH1, 10, false);

    Indio.analogWrite(AOUT_CH2, 0, false);

  }

 

 

  if (Indio.digitalRead(GREENIN)==1)

  {

    Indio.analogWrite(AOUT_CH1, 0,false);

    Indio.analogWrite(AOUT_CH2, 10, false);

  }

 

 

  if (Indio.digitalRead(YELLOWIN)==1)

  {

    Indio.analogWrite(AOUT_CH1, 10,false);

    Indio.analogWrite(AOUT_CH2, 10,false);

  }

 delay (5000); //Check in google how to make timmer without delay on arduino IDE

}

 

Maybe is not the best, but is a guide for you.

Carlos Flores
Carlos Flores
14
| 0 0 0
Answered on 8/10/23, 6:43 PM
0
vote

Your answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

Ask a Question

Keep Informed

About This Forum

This community is for professionals and enthusiasts of our products and services.

Read Guidelines

Question tools

68 follower(s)

Stats

Asked: 7/21/23, 7:59 PM
Seen: 402 times
Last updated: 3/29/24, 7:49 AM