Christmas is coming and I decide to do some light project.
And description of the problem:
here is the code that is working:
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
for (unsigned char i = 11; i < 14; pinMode(i++, OUTPUT));
}
void loop() {
if (Serial.available() >= 3) for (unsigned char i = 0, my_buffer[3],b=11; i < 3; digitalWrite(b++,my_buffer[i++] = Serial.read()));
// put your main code here, to run repeatedly:
}
So vixen sends through serial some data I grab it when 3 or more chars are available (as per my config vixen deals with 3 outputs only) store them in my_buffer and send to digitalWrite to do its work.
As lights are coming on and off as expected I assume that vixen sends some data which contains 0 in it or else lights will not turn off as per digitalwrite source:
But as I have strings of leds I want to use my i2c servo motor board which has 1.25A output per channel which is ok for 60 leds strip 20ma per led. Board has mcp23008 i2c port expander.
In second for loop I`m packing or at least trying to pack char array into 1 byte. To send to mcp23008 via i2c as 1 byte in 1 transmission to keep up with vixelights stream.
One of the problems is I don't have mega or any board with 2 serial ports to check what Im getting and what Im outputting. This second code is not working on the board problem is in the way I`m packing the data into 1 byte but so far cant figure out.
You realize that the MCP23008 can only drive low, right?
Have you tested with just sending a known value to the MCP23008? I suspect that you'll find that it doesnt work, because there's a problem with your wiring
Didnt get what u mean by saying mcp23008 can drive only low?
Board is working with 7 servo motors simultaneously without problems . Each port is tested board is working great plus others are using it on robot projects.
And the schematic of that board is where? And how is that board connected to the light string?
Have you verified that you can make it work by sending a fixed byte to the mcp23008? That will tell you whether the problem is with your parsing of the received data, or the wiring. You clearly suspect the former; I suspect the latter.
The outputs of the mcp23008 are open drain with a weak pull-up. They can sink tens of mA when they are trying to drive low, but they cant drive high - all they can do is turn on the internal pullup and stop driving the pin low.
But I see a bunch of transistors there, so theres more to it than just the port expander, and you havent posted a schematic, so who knows what it's doing? (Clearly neither of us, since you can't make it work and I dont have the schematic)
If there was a problem with a board then i would ask solution on hardware part but as board is tested by me and by others on their robot projects without any issues i am sure the problem is in the block of the code i mentioned.
So again board with working with 4x60led strips attached with simple for loop which is switching on and off leds.
Vixenlights is working good with serial read into array and then output it with digitalwrite.
I want to pack vixenlight stream of 3 chara into 1 byte to be able to send via i2c at once.
Or if someone knows what data is vixen sending that would be a huge help.