Go Down

Topic: 8 x RGB LED Array (Read 2 times) previous topic - next topic

CrossRoads

Wrap this part with ID checking code:
Code: [Select]

if (buf[0]== intended_ID){
////////////////////////////////////////////////////////Set RGB Colour With CAN Message


  maskBit = 1;                                  // start with B00000001

for (x=0; x<8; x=x+1){
 
if ((buf[0] & maskBit) >0){                 // makes all bits but 1 low: 0000000C, next pass 000000C0, etc

digitalWrite (pinsArray[x],  HIGH);
}

else {
 
digitalWrite (pinsArray[x], LOW);
}



maskBit = maskBit << 1;   // next bit - B00000010, B00000100, B00001000, etc up to B10000000
}

////////////////////////////////////////////////////////////////////////////////////////////////Write LED Pattern
}// next x

} // end ID check
else{
// add code to loop thru the pins with digitalWrite(pin, LOW)
}
Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Rich_P

Thanks, im just waitinf for the correct command from the cuy that wrote the library to try it out, but looks great,

Any idea why when the CAN message is removed, or i disconnect the board from the CAN bus, it seems to display the last recieved sequence on the lights,

In principal, it should be able to show more than one colour at a time as the CAN speed is high enough, and writing some simple code of digital write high's and low's allows me to do it,

I think i may have something in there that is taking to long, or it isnt clearing the messge buffer fast enough,

What do you think?

Cheers

Rich

Go Up