We are about to switch to a new forum software. Until then we have removed the registration on this forum.
As the title alludes to, I'm in the process of converting an Arduino sketch to a Processing sketch. So far, mostly pretty straightforward.
I'm running into an issue with creating an array of ints for the channels for two muxers. Below is the code that I currently have working for the Arduino sketch:
int writeMux(int channel){
int controlPin[] = {s0, s1, s2, s3, s4, s5, s6, s7};
int muxChannel[20][8]={
//Mux 1
{0,0,0,0,0,0,0,0}, //channel 0
{1,0,0,0,0,0,0,0}, //channel 1
{0,1,0,0,0,0,0,0}, //channel 2
{1,1,0,0,0,0,0,0}, //channel 3
{0,0,1,0,0,0,0,0}, //channel 4
{1,0,1,0,0,0,0,0}, //channel 5
{0,1,1,0,0,0,0,0}, //channel 6
{1,1,1,0,0,0,0,0}, //channel 7
{0,0,0,1,0,0,0,0}, //channel 8
{1,0,0,1,0,0,0,0}, //channel 9
//Max 2
{1,1,1,1,0,0,0,0}, //channel 0
{1,1,1,1,1,0,0,0}, //channel 1
{1,1,1,1,0,1,0,0}, //channel 2
{1,1,1,1,1,1,0,0}, //channel 3
{1,1,1,1,0,0,1,0}, //channel 4
{1,1,1,1,1,0,1,0}, //channel 5
{1,1,1,1,0,1,1,0}, //channel 6
{1,1,1,1,1,1,1,0}, //channel 7
{1,1,1,1,0,0,0,1}, //channel 8
{1,1,1,1,1,0,0,1}, //channel 9
};
//loop through the 4 sig
for(int i = 0; i < 8; i ++){
digitalWrite(controlPin[i], muxChannel[channel][i]);
}
//write the value at the SIG pin
analogWrite(SIG_pin, testValue);
//return the value
return 0;
}
Below is the slightly varied version that I'm using for my Processing-equivelent sketch.
int readMux(int channel){
int controlPin[] = {s0, s1, s2, s3};
int muxChannel[20][8]={
//Mux 1
{0,0,0,0,0,0,0,0}, //channel 0
{1,0,0,0,0,0,0,0}, //channel 1
{0,1,0,0,0,0,0,0}, //channel 2
{1,1,0,0,0,0,0,0}, //channel 3
{0,0,1,0,0,0,0,0}, //channel 4
{1,0,1,0,0,0,0,0}, //channel 5
{0,1,1,0,0,0,0,0}, //channel 6
{1,1,1,0,0,0,0,0}, //channel 7
{0,0,0,1,0,0,0,0}, //channel 8
{1,0,0,1,0,0,0,0}, //channel 9
//Max 2
{1,1,1,1,0,0,0,0}, //channel 0
{1,1,1,1,1,0,0,0}, //channel 1
{1,1,1,1,0,1,0,0}, //channel 2
{1,1,1,1,1,1,0,0}, //channel 3
{1,1,1,1,0,0,1,0}, //channel 4
{1,1,1,1,1,0,1,0}, //channel 5
{1,1,1,1,0,1,1,0}, //channel 6
{1,1,1,1,1,1,1,0}, //channel 7
{1,1,1,1,0,0,0,1}, //channel 8
{1,1,1,1,1,0,0,1}, //channel 9
};
//loop through the 4 sig
for(int i = 0; i < 4; i ++){
digitalWrite(controlPin[i], muxChannel[channel][i]);
}
//write the value at the SIG pin
arduino.analogWrite(SIG_pin, testValue);
int val = 0;
return val;
}
I'm currently getting an error of unexpected token: int error at the following line:
int muxChannel[20][8]={
And, an error of The type of expression must be an array type but it resolved to int at this line
:
digitalWrite(controlPin[i], muxChannel[channel][i]);
I'm by no means a Java expert, so I'm not exactly sure what's going on. Anyone able to offer some insight?
Thank you!
Answers