Home
About
Blog
Devices
Projects
Actuators
Resources
Suppliers
Techniques

Techniques - Selecting

Selecting can be done in two ways, analogue or digital. The technique shown below shows an analogue resistive ladder with tapping points. This is handy if you run out of digital pins.

Circuit Diagram Rotary Switch (resitive ladder) Arduino Code Snippet.
Resistive Ladder
Resitive Select
valInstSelect = analogRead(4);
valRange = valInstSelect;
// Resistor change range 0, 203, 408, 613, 819, 1023. see analog test routine.
if (valRange <=100) // Is it Piano
{ instrument_type1 = acoustic_grand_piano; }
else if(valRange <=250) // Is it a piccolo
{ instrument_type1 = piccolo; }
else if(valRange <=500) // Is it jazz guitar
{ instrument_type1 = electric_guitar_jazz; }
else if(valRange <=700) // Is it slow strings
{ instrument_type1 = slow_strings; }
else if(valRange <=900) // Is it a cello
{ instrument_type1 = cello; }
else if(valRange <1050) // Is it choir aahs
{ instrument_type1 = choir_aahs; }

This technique uses two input digital pins on the Arduino set to HI, the output BA == 00,01,10,11.

  Rotary Switch (Binary Output) Arduino Code Snippet.
Rotary Switch - Binary
// == MODE SELECT =====
if (ModeLine_B==0 && ModeLine_A==0)
{DeviceMode = 0;
}
else if (ModeLine_B==0 && ModeLine_A==1)
{DeviceMode = 1;}
else if (ModeLine_B==1 && ModeLine_A==0)
{DeviceMode = 2;}
else if(ModeLine_B==1 && ModeLine_A==1)
{DeviceMode = 3;}

 

 

Home
About
Blog
Devices
Projects
Actuators
Resources
Suppliers
Techniques