密码一键自动输入器(Arduino) – Arduino 实验室


MAKER:Fredemo_ /译:趣无尽 Cherry(转载请注明出处)
设定和输入密码是一件很让人为难的事情,太简单的不安全,太复杂的记不住。
有没有既简单又安全的办法呢?实际上我们可以制作一个自动输入器,帮我们记住复杂的密码,在需要输入密码的时候,只需要按一下输入按钮就可以完成自动输入了!是不是很神奇?

这里面用到了一块单片机,实现对密码的保存和模拟键盘的输出。

材料清单


电阻10k x2
Pro Micro x1(或其他ATmega32u4芯片的Arduino
纸盒 x1(你当然可以找一个更坚固又漂亮的盒子)
按钮 x2
跳线 x若干
烙铁 x1
热熔胶枪 x1

组装



如图所示。按照图片上的电路图接线。通过电阻将Pro Micro上的VCC/RAW连接到按钮。连接Pro Micro上数字引脚的电缆将与按钮上的电源相同。最后,返回地(GND)。
最后使用热熔胶将组件固定。

输入代码

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

#include <Keyboard.h>

#define buttonPin  7 // Permanently makes buttonPin's value 7.

#define buttonPin2  5 // Permanently makes buttonPin2's value 5.

void setup() {

pinMode(buttonPin,INPUT); // Set the pins  as inputs.

pinMode(buttonPin2,INPUT);

Serial.begin(9600);

Keyboard.begin(); // Start the keayboard funktions

}

void loop() {

int buttonState = digitalRead(buttonPin); //read the state of the button input

int buttonState2 = digitalRead(buttonPin2); //read the state of the button input

if (buttonState == LOW) { //pressing the button will produce a LOW state 0V

Serial.println(buttonState);

Keyboard.print ("m05Ts3cUR3Pa55W0rDewWa"); //Enter your password here

delay (1000);

}

if (buttonState2 == LOW) { //pressing the button will produce a LOW state 0V

Keyboard.print ("5eConDm05Ts3cUR3Pa55W0rDewWa"); //Enter your second password here

delay (1000);

}

}

如果你有需要,你可以在输入你的 username / email,然后输入密码。放入这段Keyboard.print()代码就OK啦!。

1

2

3

4

5

<Keyboard.print("Your username");//输入用户名

delay(100);

Keyboard.press(KEY_TAB);//模拟键盘按一下TAB键

delay(100);

Keyboard.print("Your password"); //输入密码

全部完成!


只要把它与你的电脑相连就可以使用啦!是不是非常的简单呢!
另外,如果需要配置多组不同的密码和操作按钮,可以通过添加开关和修改程序中的相关逻辑很轻易地实现。

https://make.quwj.com/project/96


原网址: 访问
创建于: 2020-06-28 01:27:15
目录: default
标签: 无

请先后发表评论
  • 最新评论
  • 总共0条评论