Hello to all,
I ask you a favor I have to program the Arduino Leonardo so that by connecting a potentiometer if I turn from 0 to the maximum of its travel , Leonardo I simulates the pressure step of the letter " a", whereas if I go to the max to 0 simulates the pressure on me step of the letter " d " as if I did I on the keyboard , since I'm a beginner you can explain step by step how to write the program and how to connect it without making a mess .
Here below I enclose what I thought but I will not work :
value = analogRead (pin number) / 100 ;
if ( value ! = old value ) ;
if value> old value keybord.press ( 'a ' ) ;
keybord.release ( 'a ' ) ;
keybord.release else ( ' d ' ) ;
Also I ask politely if I explain step by step how I have programmed correctly, and properly connect the shield card mux 2 that I purchased to increase the key inputs to the Arduino Leonardo .
Thanks a lot to everyone
Diego
There are a few things wrong with your snippet, including the fact that you don't have valid C/C++ code
Why are you keeping the key pressed? Why not use Keyboard.print(). Also, note the spelling - yours is wrong.
You are not checking if the potentiometer goes all the way to 0 or 1023. The way you have it even the slightest change would cause a key change.
Look at the Reference pages to see the correct syntax for IF and ELSE statements. What you have is wrong.
...R
if I turn from 0 to the maximum of its travel , Leonardo I simulates the pressure step of the letter " a"
So, you want to send the letter 'a' when the potentiometer is at the upper end of the travel, and the letter 'd' when it is at the lower end? Or, do you want to send 'a' every time you read a value that is higher than last time, and the letter 'd' each time you read a value that is lower than last time?
Clear requirements are absolutely essential BEFORE you start coding.