rest and cahnging effect with rotary encoder

6 years 5 months ago #1361 by 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
The following user(s) said Thank You: Ray

Please Log in to join the conversation.

6 years 5 months ago #1362 by Ray
Thanks for your contribution !!! you can maybe upload a pic of your system in the future :P all the best!

Please Log in to join the conversation.

Time to create page: 0.053 seconds
Powered by Kunena Forum
Joomla SEF URLs by Artio

Follow us

You can also follow us on:

facebook   google   instagram

pinterest   youtube   twitter