I was only recently exposed to Arduino for a couple of days. This is how far I got before I hit the brick wall.
The goal of this simple project is to get key presses to occur in a sequence and then repeat a set amount of times.
The pin is from ground to pin 2 on the Arduino Leonardo board.
I am not trying to enter text into a text box such as print but to actually get functional key presses without using a breadboard unless it is necessary.
I don't know if I will need Scan Codes, Hexadecimal values or Decimal values however, I understand I am lacking some understanding of syntax or the way it is placed together from the libraries and reference pages.
Am I on the right track?
It needs to press tab 1,2,3,1,2,3,f10 pause for 1 minute then repeat for a specified amount of times. Simple goal right?
another interesting code is this one: for (int x=0; x<3; x++){ if you change 3 to another number it will repeat how many times the set
of keys will be pressed in the { }. These are all the tools I understand for now.
This presses 11 instead of 1 1 what happened to the tab key being pressed?
No error codes.
It's the software you download for the Arduino
Arduino ERW 1.0.4
I'm not using a separate software. Whether it can run it or not is beyond me.
Is there another way I can test it. I ran the program in Microsoft word.
You might be able to achieve that by programming the Arduino to emulate a keyboard, and that's certainly possible, but there may be a simpler way to achieve what you're trying to achieve.
Which begs the question: What are you actually trying to achieve?
I guess you are trying to send keyboard input to some PC application, in which case it'd help if you described what type of application it is and what OS the PC is running. For example, on Windows there are various ways to send keyboard events to an application and none of them are difficult, if you are willing to consider a solution that involves software installed on the PC.
I have tested your sketch, and found two problems.
You started too soon after a reset. I added a delay of 500ms.
If the 'KEY_TAB' is active for 500ms, the autorepeat could turn it into two keystrokes. A normal value would be 100ms. I use Keyboard.write() now.
void setup()
{
pinMode(2,INPUT);
digitalWrite(2,HIGH);
Keyboard.begin();
// Wait half a second before starting the sketch.
delay(500);
// Wait for the button.
while(digitalRead(2))
{
}
// Send '1', 'KEY_TAB', '1'
// Works in Notepad and in the Arduino editor itself.
Keyboard.write( '1');
Keyboard.write( KEY_TAB);
Keyboard.write( '1');
}
void loop()
{
}
Could you try this in notepad ?
And after that in Microsoft Word ?
If it still doesn't work, could you check the usb port and usb cable ?
Thank you PeterH for giving me better direction with the project I am working on.
I am programming the Arduino to emulate a keyboard's function so I can be hands free with a repetitive tasks.
To answer your question I am running Windows 7. This might tell me why the tab code wasn't working or what codes to communicate with it. However, a keyboard will work no matter what Operating System you are using as hardware. How does a keyboard know all the codes to all the OS. Isn't there something like scan codes that will do what I am looking for?
I am not trying to tell a software program to communicate with another software program.
I am looking at this more from a basic perspective.
For my goal I don't believe it will matter what software program this is for. It should work for anything and everything.
In short the computer should think only the Keyboard communicating with the PC.
Thanks for your help in this; I appreciate it.