rest and cahnging effect with rotary encoder

6 años 1 día antes #1361 por freddylamenace
Hi,

I can select effect with a rotary encoder and reset with switch ( Reset arduino Due when the voltage of pin RESET is ground)/

You need ;
- rotary encoder with switch without breakout board,
- two 10 Kohms resistor
- wires,

Schematic :

PIN 15-10 Kohms---GND
PIN 14--10 Kohms--GND

PIN 14- | |- GND
+ 5V----| |
PIN 15- | |-RESET

- connect ground,
- connect RESET to RESET DUE (next to 3.3 V pin)

- connect to 5 volts,
- connect pin14 and 15,
- wire 10 Kohms resistor between GND and pin 14,
- wire 10 Kohms resistors between GND and pin 15,

add this part of code :

.........
int encoder0Pos = 0;
int encoder0PinALast = LOW;
int n = LOW;

void setup(){
......................
pinMode(14,INPUT);
pinMode(15,INPUT);
.........
}

void loop(){
...........
n = digitalRead(15);
if ((encoder0PinALast == LOW) && (n == HIGH)) {
if (digitalRead(14) == LOW) { effect--; if (effect <0){effect=N_EFFECT ; } }
else { effect++; if (effect>N_EFFECT){effect=0;} }
}
encoder0PinALast = n;
.........
}


If it's the wrong way, permut PIN 14 and 15 in void loop.

Easy transformation for great results

Fred
El siguiente usuario dijo gracias: Ray

Por favor, Identificarse para unirse a la conversación.

6 años 12 horas antes #1362 por Ray
Thanks for your contribution !!! you can maybe upload a pic of your system in the future :P all the best!

Por favor, Identificarse para unirse a la conversación.

Tiempo de carga de la página: 0.055 segundos
Gracias a Foro Kunena
Joomla SEF URLs by Artio