Announcement
Collapse
No announcement yet.
MUX
Collapse
X
-
Code:int Ctrl_A = 7; int Ctrl_B = 6; int Ctrl_C = 4; ... pinMode(Ctrl_A, OUTPUT); pinMode(Ctrl_B, OUTPUT); pinMode(Ctrl_C, OUTPUT); ... // ***** TRUTH TABLE ***** // C B A "ON" Channel(S) // *** *** *** *************** // 0 0 0 0 // 0 0 1 1 // 0 1 0 2 // 0 1 1 3 // 1 0 0 4 // 1 0 1 5 // 1 1 0 6 // 1 1 1 7 // ********************************* digitalWrite(Ctrl_A, value); // HIGH or LOW digitalWrite(Ctrl_B, value); // HIGH or LOW digitalWrite(Ctrl_C, value); // HIGH or LOW
-
or using direct pin manipulating (approx 12 x faster):
Code:DDRD |= (1<<DDD7) ; DDRD |= (1<<DDD6) ; DDRD |= (1<<DDD4) ; ... // ***** TRUTH TABLE ***** // C B A "ON" Channel(S) // *** *** *** *************** // 0 0 0 0 // 0 0 1 1 // 0 1 0 2 // 0 1 1 3 // 1 0 0 4 // 1 0 1 5 // 1 1 0 6 // 1 1 1 7 // ********************************* // PORTD &=~ (1<<PORTD7); // (LOW); // OR // PORTD |=(1<< PORTD7); // (HIGH); // PORTD &=~ (1<<PORTD6); // (LOW); // OR // PORTD |=(1<< PORTD6); // (HIGH); // PORTD &=~ (1<<PORTD4); // (LOW); // OR // PORTD |=(1<< PORTD4); // (HIGH);
Comment
-
This was specific demand, to select between 8 stereo channels.
Things can be more interesting if inhibit was included in to be controlled by mcu.
Davor pointed me on Vee "problematic" when line level signals are switched so i added 7660 as the easiest choice for me at the moment.
Things can be done even simpler.
...
Consider this as Easter treat.
Comment
Comment