Hi
I need to poll some potentiometers and buttons through 4x 4051-multiplexers .. the potentiometers work well, but I have no idea how I would get if a button is pressed?
the first row-dials are the first 4051 .. works
the second row-dials are the second 4051 ..works
the third row are the buttons.. here i have no idea how to poll if it is pressed(?)
int i; // select y-input
void setup(void){
palSetPadMode(GPIOC,0,PAL_MODE_OUTPUT_PUSHPULL); // s0 Pin of 4051
palSetPadMode(GPIOC,1,PAL_MODE_OUTPUT_PUSHPULL); // S1 Pin of 4051
palSetPadMode(GPIOC,2,PAL_MODE_OUTPUT_PUSHPULL); // s2 Pin of 4051
palSetPadMode(GPIOC,5,PAL_MODE_INPUT_PULLDOWN);
i = 0;
}
void loop(void){
i++;
if (i == 32) {
i = 0;
}
palWritePad(GPIOC,0,((i& 0x01) > 0)); // write s0
palWritePad(GPIOC,1,(((i>>1)& 0x01) > 0)); // write s1
palWritePad(GPIOC,2,(((i>>2)& 0x01) > 0)); // write s2
int z = adcvalues[13]<<15; // ADC z-input
int z1 = adcvalues[14]<<15; // ADC z-input
int z2 = palReadPad(GPIOC,5); // ADC z-input
int z3 = adcvalues[0]<<15; // ADC z-input
switch (i){
case 0: PExParameterChange(&parent->PExch[PARAM_INDEX_y0_value],z,0xFFFD); break; //connect in1 to dial (named y0)
case 1: PExParameterChange(&parent->PExch[PARAM_INDEX_y1_value],z,0xFFFD); break; //connect in2 to dial (named y1)
case 2: PExParameterChange(&parent->PExch[PARAM_INDEX_y2_value],z,0xFFFD); break; //connect in3 to dial (named y2)
case 3: PExParameterChange(&parent->PExch[PARAM_INDEX_y3_value],z,0xFFFD); break; //connect in4 to dial (named y3)
case 4: PExParameterChange(&parent->PExch[PARAM_INDEX_y4_value],z,0xFFFD); break; //connect in5 to dial (named y4)
case 5: PExParameterChange(&parent->PExch[PARAM_INDEX_y5_value],z,0xFFFD); break; //connect in6 to dial (named y5)
case 6: PExParameterChange(&parent->PExch[PARAM_INDEX_y6_value],z,0xFFFD); break; //connect in7 to dial (named y6)
case 7: PExParameterChange(&parent->PExch[PARAM_INDEX_y7_value],z,0xFFFD); break; //connect in8 to dial (named y7)
case 8: PExParameterChange(&parent->PExch[PARAM_INDEX_y8_value],z1,0xFFFD); break; //connect in1 to dial (named y0)
case 9: PExParameterChange(&parent->PExch[PARAM_INDEX_y9_value],z1,0xFFFD); break; //connect in2 to dial (named y1)
case 10: PExParameterChange(&parent->PExch[PARAM_INDEX_y10_value],z1,0xFFFD); break; //connect in3 to dial (named y2)
case 11: PExParameterChange(&parent->PExch[PARAM_INDEX_y11_value],z1,0xFFFD); break; //connect in4 to dial (named y3)
case 12: PExParameterChange(&parent->PExch[PARAM_INDEX_y12_value],z1,0xFFFD); break; //connect in5 to dial (named y4)
case 13: PExParameterChange(&parent->PExch[PARAM_INDEX_y13_value],z1,0xFFFD); break; //connect in6 to dial (named y5)
case 14: PExParameterChange(&parent->PExch[PARAM_INDEX_y14_value],z1,0xFFFD); break; //connect in7 to dial (named y6)
case 15: PExParameterChange(&parent->PExch[PARAM_INDEX_y15_value],z1,0xFFFD); break; //connect in8 to dial (named y7)
case 16: out2 = z2; break;
//case 16: PExParameterChange(&parent->PExch[PARAM_INDEX_y16_value],z2,0xFFFD); break; //connect in2 to dial (named y1)
case 17: PExParameterChange(&parent->PExch[PARAM_INDEX_y17_value],z2,0xFFFD); break; //connect in3 to dial (named y2)
case 18: PExParameterChange(&parent->PExch[PARAM_INDEX_y18_value],z2,0xFFFD); break; //connect in4 to dial (named y3)
case 19: PExParameterChange(&parent->PExch[PARAM_INDEX_y19_value],z2,0xFFFD); break; //connect in5 to dial (named y4)
case 20: PExParameterChange(&parent->PExch[PARAM_INDEX_y20_value],z2,0xFFFD); break; //connect in6 to dial (named y5)
case 21: PExParameterChange(&parent->PExch[PARAM_INDEX_y21_value],z2,0xFFFD); break; //connect in7 to dial (named y6)
case 22: PExParameterChange(&parent->PExch[PARAM_INDEX_y22_value],z2,0xFFFD); break; //connect in8 to dial (named y7)
}
}
can someone please help me?