Author Topic: Help with Arduino Mega code  (Read 159 times)

Offline Eloir

  • Newbie
  • *
  • Join Date: Dec 2018
  • Location:
  • Posts: 1
  • Kudos: 0
Help with Arduino Mega code
« on: December 10, 2018, 09:47:46 PM »
Hello I am new and I want to connect an arduino Mega to some lights that I have, I install a code with 44 outputs for SSR in the arduino and only work 12 outputs, I need more outputs, better if you can dimming and if is not possible, with digital outputs it's very good.
Can someone recommend me some mega arduino code to use relay outputs?
I use this:



/*
  44PWM CHANNELS ON ARDUINO MEGA - by z0mbie st0mp
  REQUIRES SoftPWM LIBRARY WITH MODIFIED MAX CHANNELS
  WRITTEN FOR USE WITH FALCON PI PLAYER
  UNTESTED IN PC/VIXEN ENVIRONMENT, BUT SHOULD WORK
*/


#include <SoftPWM.h>
#include <SoftPWM_timer.h>




void setup()
{
  // Initialize Serial
  Serial.begin(9600); // set up Serial at 9600 bps
  // Initialize SoftPWM
  SoftPWMBegin();


  // Create and set pins for PWM use and turn them off


  SoftPWMSet(2, 0);
  SoftPWMSet(3, 0);
  SoftPWMSet(4, 0);
  SoftPWMSet(5, 0);
  SoftPWMSet(6, 0);
  SoftPWMSet(7, 0);
  SoftPWMSet(8, 0);
  SoftPWMSet(9, 0);
  SoftPWMSet(10, 0);
  SoftPWMSet(11, 0);
  SoftPWMSet(12, 0);
  SoftPWMSet(13, 0);
  SoftPWMSet(22, 0);
  SoftPWMSet(23, 0);
  SoftPWMSet(24, 0);
  SoftPWMSet(25, 0);
  SoftPWMSet(26, 0);
  SoftPWMSet(27, 0);
  SoftPWMSet(28, 0);
  SoftPWMSet(29, 0);
  SoftPWMSet(30, 0);
  SoftPWMSet(31, 0);
  SoftPWMSet(32, 0);
  SoftPWMSet(33, 0);
  SoftPWMSet(34, 0);
  SoftPWMSet(35, 0);
  SoftPWMSet(36, 0);
  SoftPWMSet(37, 0);
  SoftPWMSet(38, 0);
  SoftPWMSet(39, 0);
  SoftPWMSet(40, 0);
  SoftPWMSet(41, 0);
  SoftPWMSet(42, 0);
  SoftPWMSet(43, 0);
  SoftPWMSet(44, 0);
  SoftPWMSet(45, 0);
  SoftPWMSet(46, 0);
  SoftPWMSet(47, 0);
  SoftPWMSet(48, 0);
  SoftPWMSet(49, 0);
  SoftPWMSet(50, 0);
  SoftPWMSet(51, 0);
  SoftPWMSet(52, 0);
  SoftPWMSet(53, 0);


}


// Initialize Loop counter
int i = 0;
// Set array to store the 30 values from the serial port
int incomingByte[44];


void loop()
{ // 30 channels are coming in to the Arduino
  if (Serial.available() >= 44) {
    // read the oldest byte in the serial buffer:
    for (int i = 0; i < 44; i++) {
      // read each byte
      incomingByte = Serial.read();
    }


    SoftPWMSet(2, incomingByte[0]);
    SoftPWMSet(3, incomingByte[1]);
    SoftPWMSet(4, incomingByte[2]);
    SoftPWMSet(5, incomingByte[3]);
    SoftPWMSet(6, incomingByte[4]);
    SoftPWMSet(7, incomingByte[5]);
    SoftPWMSet(8, incomingByte[6]);
    SoftPWMSet(9, incomingByte[7]);
    SoftPWMSet(10, incomingByte[8]);
    SoftPWMSet(11, incomingByte[9]);
    SoftPWMSet(12, incomingByte[10]);
    SoftPWMSet(13, incomingByte[11]);


    SoftPWMSet(22, incomingByte[12]);
    SoftPWMSet(23, incomingByte[13]);
    SoftPWMSet(24, incomingByte[14]);
    SoftPWMSet(25, incomingByte[15]);
    SoftPWMSet(26, incomingByte[16]);
    SoftPWMSet(27, incomingByte[17]);
    SoftPWMSet(28, incomingByte[18]);
    SoftPWMSet(29, incomingByte[19]);
    SoftPWMSet(30, incomingByte[20]);
    SoftPWMSet(31, incomingByte[21]);
    SoftPWMSet(32, incomingByte[22]);
    SoftPWMSet(33, incomingByte[23]);
    SoftPWMSet(34, incomingByte[24]);
    SoftPWMSet(35, incomingByte[25]);
    SoftPWMSet(36, incomingByte[26]);
    SoftPWMSet(37, incomingByte[27]);
    SoftPWMSet(38, incomingByte[28]);
    SoftPWMSet(39, incomingByte[29]);
    SoftPWMSet(40, incomingByte[30]);
    SoftPWMSet(41, incomingByte[31]);
    SoftPWMSet(42, incomingByte[32]);
    SoftPWMSet(43, incomingByte[33]);
    SoftPWMSet(44, incomingByte[34]);
    SoftPWMSet(45, incomingByte[35]);
    SoftPWMSet(46, incomingByte[36]);
    SoftPWMSet(47, incomingByte[37]);
    SoftPWMSet(48, incomingByte[38]);
    SoftPWMSet(49, incomingByte[39]);
    SoftPWMSet(50, incomingByte[40]);
    SoftPWMSet(51, incomingByte[41]);
    SoftPWMSet(52, incomingByte[42]);
    SoftPWMSet(53, incomingByte[43]);
  }
}

 

Back to top