I have a board that controls 48 small electric motors, the board uses what I think is called multiplex (according to that 4x4x4 led cube tutorial) I've attached a text schematic below. my pins are all wired to the input side of an optocoupler before using transistors to switch the main voltage.
Simply, I'm trying to send a string through serial (eg. 66V) to make motor 36 rotate.
I can change the code
digitalWrite(column[Message[0]], HIGH);
digitalWrite(layer[Message[1]], LOW);
to
digitalWrite(7, HIGH);
digitalWrite(10, LOW);
which will allow the motor to rotate, but trying to use message[0] doesn't write the pin high.
I've tried adding extra parenthesis but can't find any other information on the exact topic. I did find another post but it only deals with 1 serial input.
I'm also using the V as a check to ensure reading one of 3 specific codes I'm planning to send.
5v 5v 5v 5v 5v 5v
0v 1 2 3 4 5 6
0v 7 8 9 10 11 12
0v 13 14 15 16 17 18
0v 19 20 21 22 23 24
0v 25 26 27 28 29 30
0v 31 32 33 34 35 36
0v 37 38 39 40 41 42
0v 43 44 45 46 47 48
IF left is 5V and top is 0V motor runs
/*
[columns-Pin]
1-2
2-3
3-4
4-5
5-6
6-7
7-8
8-9
[layer-Pin]
A-A1
B-A0
C-13
D-12
E-11
F-10
*/
//initializing and declaring motor columns
int column[8]={2,3,4,5,6,7,8,9};
//initializing and declaring shelf layers
int layer[6]={10,11,12,13,A1,A0};
const unsigned int MAX_MESSAGE_LENGTH = 3;
char Message[3] ={'-', '-', '-'};
void setup()
{
// opens serial port, sets data rate to 9600 bps
Serial.begin(9600);
//setting rows to ouput
for(int i = 0; i<8; i++)
{
pinMode(column[i], OUTPUT);
}
//setting layers to output
for(int i = 0; i<6; i++)
{
pinMode(layer[i], OUTPUT);
}
//setting layers to high
for(int i = 0; i<6; i++)
{
digitalWrite(layer[i], 1);
}
}
void loop()
{
//Check to see if anything is available in the serial receive buffer
while (Serial.available() > 0)
{
//Allow the Buffer to fill
delay(200);
//Create a place to hold the incoming message
static unsigned int message_pos = 0;
//Read the next available byte in the serial receive buffer
char inByte = Serial.read();
//Message coming in (check not terminating character) and guard for over message size
if ( inByte != '\n' && (message_pos - MAX_MESSAGE_LENGTH - 1) )
{
//Add the incoming byte to our message
Message[message_pos] = inByte;
message_pos++;
}
//Full message received...
else
{
//Add null character to string
Message[message_pos] = '\0';
//Reset for the next message
message_pos = 0;
}
}
if (Message[2] == 'V')
{
Serial.println(Message);
digitalWrite(column[Message[0]], HIGH);
digitalWrite(layer[Message[1]], LOW);
delay(20000); // #####
delay(200); // #####
digitalWrite(column[Message[0]], LOW);
digitalWrite(layer[Message[1]], HIGH);
Serial.println("Signal done");
Message[0] = '-';
Message[1] = '-';
Message[2] = '-';
}
else
{
}
}