username entry made easy?

Hi,

I have been using an Arduino Uno for a little while, I am now using a Leonardo and have developed the idea for using it to type usernames etc, using the keyboard emulation.

I find myself entering the same username at work up to 50 times a day, mainly it's just a little project to get my teeth into. A little lazy I know.

I have written this code:

const int passButton = 1;
const int pass1Button = 2;
const int usernameButton = 3;
const int emailButton = 4;

void setup()
{
pinMode(passButton, INPUT);
pinMode(pass1Button, INPUT);
pinMode(usernameButton, INPUT);
pinMode(emailButton, INPUT);
Keyboard.begin();
}

void loop()
{
if (digitalRead(passButton) == HIGH)
{
Keyboard.print("Password\n");
}
if (digitalRead(pass1Button) == HIGH)
{
Keyboard.print("Password1\n");
}
if (digitalRead(usernameButton) == HIGH)
{
Keyboard.print("user.a.name");
}
if (digitalRead(emailButton) == HIGH)
{
Keyboard.print("user.a.name@work.com");
}
delay(300);
}

Code appears to work but just needs a little work I think?

I had a problem with debouncing, which I have now sorted (fingers crossed) by using a hardware debounce setup.

I still have 2 other problems:

  1. When pass1 or username buttons are pressed, it prints any random combination of the keyboard.prints for example (pass, pass1, user.a.name, user.a.name"work.com).

Don't have this problem with either the pass or email buttons, not sure what the issue is?

  1. The other issue is that it doesn't print an @, instead it prints ".

Is there a way of changing that? or is it a disallowed character?

Any help would be gratefully received

Regards

Andy Clements

clemmy23:

  1. When pass1 or username buttons are pressed, it prints any random combination of the keyboard.prints for example (pass, pass1, user.a.name, user.a.name"work.com).

Don't have this problem with either the pass or email buttons, not sure what the issue is?

Sounds like you don't have pull-down resistors on all your input pins.

Hi,

I am using the same button for the time being and just altering the pin it's connected to until I can get this bug fixed, then I'll wire the whole thing up in breadboard before soldering the finished circuit onto some stripboard.

Am I missing an else command?

Cheers

Andy

clemmy23:
I am using the same button for the time being and just altering the pin it's connected to until I can get this bug fixed, then I'll wire the whole thing up in breadboard before soldering the finished circuit onto some stripboard.

Do you have pull-down resistors on the pins that are not connected to the buttons?
An alternative is to use internal pull-ups. You will have to connect the button(s) between the input pins and Ground (not +5).

const int passButton = 1;
const int pass1Button = 2;
const int usernameButton = 3;
const int emailButton = 4;

void setup()
{
 pinMode(passButton, INPUT_PULLUP);
 pinMode(pass1Button, INPUT_PULLUP);
 pinMode(usernameButton, INPUT_PULLUP);
 pinMode(emailButton, INPUT_PULLUP);
 Keyboard.begin();
}

void loop()
{
 if (digitalRead(passButton) == LOW)
 {
   Keyboard.print("Password\n");
 }
 if (digitalRead(pass1Button) == LOW)
 {
   Keyboard.print("Password1\n");
 }
 if (digitalRead(usernameButton) == LOW)
 {
   Keyboard.print("user.a.name");
 }
 if (digitalRead(emailButton) == LOW)
 {
   Keyboard.print("user.a.name@work.com");
 }
 delay(300);
}

clemmy23:
Hi,

I have been using an Arduino Uno for a little while, I am now using a Leonardo and have developed the idea for using it to type usernames etc, using the keyboard emulation.

I find myself entering the same username at work up to 50 times a day, mainly it's just a little project to get my teeth into. A little lazy I know.

Not only lazy but also highly insecure. What's to stop someone else getting hold of it and using your username and password?
Try explaining to your employer how porn was downloaded using your name.

Hi John,

Have it working now using your suggestions, thank you very much. I also moved them to digital pins 10-13 in case there was an issue with the pins themselves.

I have discovered that to print an @ on a UK keyboard using an Arduino, the code needs to be:

Keyboard.print("user.a.name"work.com");

Regards

Andy