Guitar Case Detector Design
A guitar case detector circuit comprises a voltage divider with a 1KΩ resistor in series with a 100kΩ resistor on the circuit board with the junction between the two resistors being fed to an analogue input on an Arduino Nano.
Plugging in a guitar case puts another resistor in parallel with the 100kΩ resistor, hence changing the resistance on the ground side of the voltage divider, as hence changing the voltage at the analogue pin.
The circuit is arranged like this:
By using a different value resistor in each guitar case we can detect which guitar case is plugged in.
To help determine the resistors to use, an experiment was undertaken with all the values of resistors I have in stock. One resistor of each value was selected at random, connected into the above circuit, and tested with an Arduino Nano that read and output a range of values of the connected Nano analogue pin. The experiment was repeated with different selection of resistors, this time with an Arduino Uno.
Note that the Nano experiment was conducted in 2021 using a sketch that output a list of all the read values and the range of values was detected by examining the list. The experiment using the Uno was conducted in August 2022 and used a sketch that read 200 values from the analogue pin and output the minimum and maximum values. The sketch was run multiple times and the results were combined. The latter sketch is available from the project GitHub repository, but the former sketch was not saved.
Key
- Parallel resistance
- The value of the resistor coupled in parallel with the 100kΩ resistor.
- Combined resistance
- The resistance of parallel combination of the 100kΩ resistor and parallel resistor, rounded to 2 significant digits.
- Analogue input reading range
- Shows the range of readings read from the Arduino Nano & Uno. Values fall in the range 0..1023, which is the maximum sensitivity of the microcontrollers’ ADC.
Parallel resistance | Combined resistance | Analogue input reading range (0-1023) |
|
---|---|---|---|
Nano | Uno | ||
Short circuit (0Ω) | 0Ω | 0-2 | 0 |
10Ω | 10Ω | 8-10 | 8-10 |
22Ω | 22Ω | 20-22 | 20-21 |
47Ω | 47Ω | 43-48 | 44-46 |
100Ω | 100Ω | 91-94 | 91-92 |
150Ω | 150Ω | 130-135 | 131-133 |
200Ω | 200Ω | 168-169 | 169-171 |
220Ω | 220Ω | 180-184 | 183-188 |
270Ω | 270Ω | 214-217 | 214-215 |
330Ω | 330Ω | 251-253 | 251-254 |
470Ω | 470Ω | 323-325 | 324-325 |
510Ω | 510Ω | 345-347 | 344-345 |
680Ω | 680Ω | 410-411 | 410-412 |
1kΩ | 990Ω | 505 | 510-512 |
2kΩ | 2.0kΩ | 676-679 | 675-676 |
2.2kΩ | 2.2kΩ | 696-697 | 700-702 |
3.3kΩ | 3.2kΩ | 776-779 | 779-781 |
4.7kΩ | 4.5kΩ | 835-839 | 834-837 |
5.1kΩ | 4.9kΩ | 844-849 | 847-850 |
6.8kΩ | 6.4kΩ | 884-888 | 883-887 |
10kΩ | 9.1kΩ | 920-922 | 921-924 |
20kΩ | 17kΩ | 963-968 | 964-967 |
47kΩ | 32kΩ | 988-992 | 991-994 |
51kΩ | 34kΩ | 991-999 | 993-996 |
68kΩ | 40kΩ | 997-1003 | 996-998 |
100kΩ | 50kΩ | 999-1005 | 1002-1005 |
220kΩ | 69kΩ | 1008-1011 | 1008-1010 |
300kΩ | 75kΩ | 1006-1011 | 1005-1007 |
470kΩ | 82kΩ | 1009-1012 | 1010-1013 |
680kΩ | 87kΩ | 1011-1012 | 1011-1014 |
1MΩ | 90kΩ | 1009-1015 | 1012-1014 |
Open circuit (∞Ω) | 100kΩ | 1008-1020 | 1013-1014 |
It can be seen that:
- There is a close correlation between the readings taken from the Nano and the Uno.
- Parallel resistances over 20kΩ have overlapping readings.
When there is no parallel resistance the resistance is 100kΩ. This is taken to mean no guitar case is plugged in.
If we try to support up to six different guitar cases, we need to choose a range of resistances that are sufficiently wide apart to remain distinct, allowing for the normal variation in resistances of the same nominal value, with a generous safety margin added.
The values chosen are:
Resistance | Purpose | Reading range |
---|---|---|
∞Ω | open circuit, no case connected | 958..1023 |
4.7kΩ | case #1 | 785..885 |
2kΩ | case #2 | 626..726 |
1kΩ | case #3 | 455..555 |
510Ω | case #4 | 295..395 |
220Ω | case #5 | 130..230 |
22Ω | case #6 | 0..70 |
Values that fall outside the reading range are consider invalid and an error should be reported.