problem with arduin...
 
Notifications
Clear all

problem with arduino mega

3 Posts
2 Users
0 Reactions
415 Views
Posts: 7
Topic starter
(@gloschkid)
Active Member
Joined: 13 years ago
[#57958]

hello,this is my first post :happy:
i have an osepp mega 2560 with 16 pwm channels controlled by vixen 2
but every now and then while the software is playing the leds will flicker
heres my code:

#include
int c1 = 3;
int c2 = 4;
int c3 = 5;
int c4 = 6;
int c5 = 7;
int c6 = 8;
int c7 = 9;
int c8 = 10;
int c9 = 11;
int c10 = 12;
int c11 = 13;
int c12 = 30;
int c13 = 31;
int c14 = 32;
int c15 = 33;
int c16 = 34;
int incomingByte[16]; // array to store the 16 values from the serial port

//setup SoftPWM
void setup()
{
//Initialize SoftPWM
SoftPWMBegin();
Serial.begin(57600);
// Create and sets row pins
for (int i = 0; i <= 19; i++)
{
SoftPWMSet(i, 0);
}
}

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

SoftPWMSet(c1, incomingByte[0]); // Write current values to LED pins
SoftPWMSet(c2, incomingByte[1]); // Write current values to LED pins
SoftPWMSet(c3, incomingByte[2]); // Write current values to LED pins
SoftPWMSet(c4, incomingByte[3]); // Write current values to LED pins
SoftPWMSet(c5, incomingByte[4]); // Write current values to LED pins
SoftPWMSet(c6, incomingByte[5]); // Write current values to LED pins
SoftPWMSet(c7, incomingByte[6]); // Write current values to LED pins
SoftPWMSet(c8, incomingByte[7]); // Write current values to LED pins
SoftPWMSet(c9, incomingByte[8]); // Write current values to LED pins
SoftPWMSet(c10, incomingByte[9]); // Write current values to LED pins
SoftPWMSet(c11, incomingByte[10]); // Write current values to LED pins
SoftPWMSet(c12, incomingByte[11]); // Write current values to LED pins
SoftPWMSet(c13, incomingByte[12]); // Write current values to LED pins
SoftPWMSet(c14, incomingByte[13]); // Write current values to LED pins
SoftPWMSet(c15, incomingByte[14]); // Write current values to LED pins
SoftPWMSet(c16, incomingByte[15]); // Write current values to LED pins

}
}

please help

and if any one can explain this part of the code it wold be helpful i found that 19 works good:

// Create and sets row pins
for (int i = 0; i <= 19; i++)

please note i am only thirteen and am not very good at programming but very good at wirring up things and ics
thanks


2 Replies
Posts: 6728
(@p-short)
Illustrious Member
Joined: 19 years ago

This is not really a good place for this message because it's fairly rare for people to look at the blog section. It would be better to put it in the Arduino section of the forum. Many more people will see your message if you post it there than if you post it here.


Reply
Posts: 7
Topic starter
(@gloschkid)
Active Member
Joined: 13 years ago

thanks im new to this so i really dont now much about it


Reply
Share: