Arduino Radio Control  Arduino Radio Control
http://www.reseau.org/arduinorc

HomePage

.

Connect a 11 positions Rotating Switch to the Arduino using a single input pin

Projects.RotSwich History

Hide minor edits - Show changes to output

Changed line 9 from:
Between each contact, I soldered a 1K resistor to make the switch act as a fixed-steps 10K potentiometer.
to:
Between each contact, I soldered a 1kΩ resistor to make the switch act as a fixed-steps 10kΩ potentiometer.
June 08, 2014, at 01:06 PM by 78.248.132.152 -
Changed line 30 from:
There is no debouncing in this code. If you need it, you'll find it in a more sophisticated function, which is available in the [[Main.Downloads|RC transmitter source code]].
to:
There is no debouncing in this code. If you need it, you'll find a more sophisticated version of this function in the [[Main.Downloads|RC transmitter source code]].
June 08, 2014, at 10:28 AM by 78.248.132.152 -
Changed line 30 from:
There is no debouncing in this code. If you need it, you'll find it in a more sophisticated function, which is available in the RC transmitter source code,
to:
There is no debouncing in this code. If you need it, you'll find it in a more sophisticated function, which is available in the [[Main.Downloads|RC transmitter source code]].
June 08, 2014, at 10:26 AM by 78.248.132.152 -
Changed lines 11-30 from:
The cursor of the switch is connected to an analog input of the Arduino, and its position is returned by this function:
to:
The cursor of the switch is connected to an analog input of the Arduino, and its position is computed with this simple code:

 // Read the position of the rotary switch
 // return value: [0, ROTARY_SWITCH_STEPS]
 #define ROTARY_SWITCH_PIN A6
 #define ROTARY_SWITCH_STEPS 10
 byte read_rotary_switch() {
byte retval_byt = 0;
const unsigned int step_int = 1024 / ROTARY_SWITCH_STEPS;
const unsigned int offset_int = step_int / 2;
unsigned int limit_int = offset_int;
unsigned int sample_int = analogRead(ROTARY_SWITCH_PIN) & 0xFFF8; // filter noise: ignore least significant 3 bits
while (sample_int > limit_int) {
retval_byt++;
limit_int += step_int;
}
return retval_byt;
 }

There is no debouncing in this code. If you need it, you'll find it in a more sophisticated function, which is available in the RC transmitter source code,
June 08, 2014, at 10:16 AM by 78.248.132.152 -
Changed lines 1-4 from:
(:title Connect a 10 positions Rotating Switch to the Arduino using a single input pin:)

I needed an easy way to select a model among 9 for my Arduino-based RC transmitter.
to:
(:title Connect a 11 positions Rotating Switch to the Arduino using a single input pin:)
%rfloat margin-top=5px margin-right=5px margin-bottom=5px margin-left=5px% {$IcoDir}/rotating_switch_schema.png
I needed an easy way to select a model among 10
for my Arduino-based RC transmitter.
Changed lines 6-7 from:
[[{$IcoDir}/rotating_switch.jpg|{$IcoDir}/rotating_switch_thumb.jpg]]"10 positions Rotating Switch"
to:

[[{$IcoDir}/rotating_switch.jpg|{$IcoDir}/rotating_switch_thumb.jpg"10 positions Rotating Switch"]]

Between each contact, I soldered a 1K resistor to make the switch act as a fixed-steps 10K potentiometer.

The cursor of the switch is connected to an analog input of the Arduino, and its position is returned by this function:
June 08, 2014, at 09:49 AM by 78.248.132.152 -
Added lines 1-7:
(:title Connect a 10 positions Rotating Switch to the Arduino using a single input pin:)

I needed an easy way to select a model among 9 for my Arduino-based RC transmitter.

I used this kind of switch, widely available on Ebay:
[[{$IcoDir}/rotating_switch.jpg|{$IcoDir}/rotating_switch_thumb.jpg]]"10 positions Rotating Switch"

 
Page last modified on February 03, 2015, at 08:39 AM