Friday, September 20, 2019

Make a Keyboard with Arduino

This project will show how can you use an USB enabled Arduino as a USB Keyboard.
I will not explain how it works from the silicon. That will be a book one it self.

So What is "USB enabled Arduino" ?

Not all Arduino can act as a USB Keyboard. Usually those board has Atmel-Mega32U4 MicroControlar can act as one. Those chip have HID support.
Like Arduino micro, Arduino Leonardo etc.
You can make an entire keyboard if you want.

What you need?

1. Arduino Micro/ Leonardo.
2. 4 Push Buttons
3. Some wires

Schematics

Wire up your parts according to the diagram And connect the Arduino to your PC/Mac.





Code

This is a simple code that will send some English character to a computer.
1. Setup the circuit as shown in the diagram above with the breadboard wires.
2. Now Plug the Arduino to your PC/Mac with USB cable.
3. Select the right board and Port from the Tools menu in Arduino IDE.

3.  Click the Upload button to send this code to your Arduino.
4. Wait for to upload to finished then reconnect the Arduino by unplugging the USB cable and re-plugging.
5. Now open "Notepad" app in your PC/MAC.
6. Push one of those button, you will see the character in the app.


Here you can see when i press tthe buttons it sends the character to the PC.


This one will send 'A', 'B', 'C', 'D' character to PC/Mac.



#include <Keyboard.h>    // This is a "built-in" library so no need to install from outside


void setup() {
pinMode(2,INPUT_PULLUP);  // sets pin 3 to input

pinMode(3,INPUT_PULLUP);  // sets pin 4 to input

pinMode(5,INPUT_PULLUP);  // sets pin 3 to input

pinMode(6,INPUT_PULLUP);  // sets pin 4 to input
}


void loop() {
 Keyboard.begin();         //First begin keyboard

 if (digitalRead(2) == 0 )  // if buton 2 is pushed
  {
    Keyboard.write('A');  // send single character "A"
    delay(200);           // delay to don't get 5 A's
  }

  if (digitalRead(3) == 0 )  // if buton 3 is pushed
  {
    Keyboard.write('B');  // send single character "B"
    delay(200);           // delay to don't get 5 B's
  }

  if (digitalRead(5) == 0 )  // if buton 5 is pushed
  {
    Keyboard.write('C');  // send single character "C"
    delay(200);           // delay to don't get 5 C's
  }

  if (digitalRead(6) == 0 )  // if buton 6 is pushed
  {
    Keyboard.write('D');  // send single character "D"
    delay(200);           // delay to don't get 5 D's
  }

  Keyboard.end();         // stops keybord
}


This one will send Up, Down, Left, Right command to PC/Mac. You can try this in a game or website.

#include <Keyboard.h>    // This is a "built-in" library so no need to install from outside


void setup() {
pinMode(2,INPUT_PULLUP);  // sets pin 3 to input

pinMode(3,INPUT_PULLUP);  // sets pin 4 to input

pinMode(5,INPUT_PULLUP);  // sets pin 3 to input

pinMode(6,INPUT_PULLUP);  // sets pin 4 to input
}

void loop() {

 Keyboard.begin();         //First begin keyboard

 if (digitalRead(2) == 0 )  // if buton 2 is pushed
  {
    Keyboard.write(KEY_UP_ARROW);
    delay(200);         
  }

  if (digitalRead(3) == 0 )  // if buton 3 is pushed
  {
    Keyboard.write(KEY_DOWN_ARROW);
    delay(200);         
  }

  if (digitalRead(5) == 0 )  // if buton 5 is pushed
  {
    Keyboard.write(KEY_LEFT_ARROW);
    delay(200);        
  }

  if (digitalRead(6) == 0 )  // if buton 6 is pushed
  {
    Keyboard.write(KEY_RIGHT_ARROW);
    delay(200);        
  }

  Keyboard.end();         // stops keybord
}


Conclusion

1. You can send any character you want in this list from 1st to 128th. Other can't because the keyboard library dose not supports others.
2. You can also use other spacial keys from this list here.
3. You can make a custom Keyboard to suit your needs. Like Video editing or Photoshop shorcuts in a keyboard.

N.T.

1. Download the library first from "Tools">> "Manage Libraries..">> "Keyboard Buit-In by Arduino ">> Click the install.
2. Select the proper board from the "Tools">> "Boards" . Or you will get error when you tried to build the code.
3. It will register/handles one button at a time. Because the code dose not supports multi pal registering key. Means if you press all of those buttons at a time it will not send all of those one time.
4. Make sure there is no loose connection and Use a good USB cable.

 Thanks.

33 comments:

  1. I got what you mean , a debt of gratitude is in order for posting .Woh I am cheerful to discover this site through google.

    Access control solutions

    ReplyDelete
  2. Thanks for the blog loaded with so many information. Stopping by your blog helped me to get what I was looking for. best programming chair

    ReplyDelete
  3. Prior to leaping to that end, why not go through the following five minutes of your life perusing what precisely is an ergonomic keyboard. mk270 keyword reviews

    ReplyDelete
  4. This was really an interesting topic and I kinda agree with what you have mentioned here! game

    ReplyDelete
  5. You should pick up a soldering iron with at least 30 watts of power. Soldering irons with low wattage take longer to heat up and are not consistent holding the temperature. Know more about Hakko brand.

    ReplyDelete
  6. Medical keyboards must be designed to accommodate the rigors of a healthcare environment. Hospitals often have significantly higher levels of radio interference due to the numerous medical devices that are deployed in combination with IT equipment. Seal Shield Medical keyboards have double shielded cables that exceed USB spec and include additional cable ferrites to eliminate radio frequency cross-talk.  Flat

    ReplyDelete
  7. I was more than happy to uncover this great site. I need to thank you for your time due to this fantastic read!!
    I definitely enjoyed every bit of it and I have you bookmarked to see new information on your blog.
    humidifier dehumidifier combo

    ReplyDelete
  8. I was more than happy to uncover this great site. I need to thank you for your time due to this fantastic read!!
    I definitely enjoyed every bit of it and I have you bookmarked to see new information on your blog.
    WordPress Chat Plugin

    ReplyDelete
  9. Really fascinating info, really worth suggesting. Nevertheless, I suggest this particular: תכנות לילדים

    ReplyDelete
  10. Dell has an assortment of pink laptops for the fashionista in you. They much offer what is considered their Promise laptop that assists battle with breasting malignancy. CPS Test

    ReplyDelete
  11. The information in the blog you posted here is useful because it contains some of the best information about Magnetic Bead Separation available. Thanks for sharing it. Keep up the good work.

    ReplyDelete
  12. Thanks for taking the time to discuss this, I feel strongly about it and love learning more on this topic. Proteus Library for Arduino

    ReplyDelete
  13. Your texts on this subject are correct, see how I wrote this site is really very good. Satta king 786

    ReplyDelete
  14. We love learning about the clients these people mark are all essential and play substantial functions within our procedure. web design and marketing company

    ReplyDelete
  15. It is quite beneficial, although think about the facts when it reaches this target. Black satta king

    ReplyDelete
  16. Zero in on the benefit
    The principal issue you wish to focus on though partaking in the Satta King 786 games is to procure a huge benefit. You should chase after the Satta assortment that includes a high probability of winning. Maybe then your fortunate assortment. There are different Satta games possible. Anyway if you are endeavoring to play each Satta King, you would perhaps not be prepared to dominate any match. Notwithstanding, if you participate in one Satta King 786, the potential outcomes of winning are overstated.

    ReplyDelete
  17. The click per second is initiated the same way as the other modes of the play like - clicks in 5 seconds, or 10 seconds or 60 seconds, but in the 1-second game the players have to be on their toes and start hitting the mouse at one breath. On average, most players would easily score between 8-10 clicks per second
    click here

    ReplyDelete
  18. With the right information and tools Bitcoin mining is not only rewarding, it's also a fun and safe way to transfer money across the internet. To make as much money as possible you need to have the right software and powerful computer hardware. fake bitcoin sender

    ReplyDelete
  19. Thanks for sharing. visit our website and check guide of how to program cox remote samsung tv

    ReplyDelete
  20. This blog is really good... keep sharing such amazing posts with us.

    If you guys are looking for the best and most cost-effective data migration services, master data management services, data integration services, and need advice for sap data management, you can contact our data analysis expert team. They will help you out with all your data concerns. Get in touch with them from - https://gluedata.com/

    ReplyDelete
  21. If you need help with your account or just have any other questions about QuickBooks, all you have to do is dial Quickbooks Customer Support Phone Number+1 888-210-4052.

    ReplyDelete
  22. Thanks for sharing such amazing content. Really loved to read such content. Keep posting such content in future as well. India assignment help

    ReplyDelete
  23. The toll free number is Quickbooks Support Phone Number +1 888-210-4052 and you need to dial that number for your queries and errors issues.

    ReplyDelete
  24. very nice information please have loo at this how to check zong balance

    ReplyDelete
  25. Nice Blog Sir, Its Very Helpful for me. Good Job & Keep it up.
    Intraday Trading Tips Share Market Expert Advisory Sharetipsinfo.com

    ReplyDelete
  26. To get instant support for QuickBooks problems, dial QuickBooks Customer Support Phone Number +1 866-669-5068. Our team makes sure to provide you with the best-in-class technical service for QuickBooks at a reasonable rate.

    ReplyDelete
  27. Thanks for sharing this information. Searching for the best luxury villa in Goa for rent? If yes then visit our company Maison 9. Appreciate remarkable vacations in north Goa at luxury private pool villa. Book now or call now 9810132318.

    ReplyDelete
  28. If your laptop has a hardware issue, or if it is faulty, you need to visit a Dell service center in Borivali. They can fix any kind of problem with your laptop and provide software installation. They can also do data recovery and clean your laptop, if necessary. Regardless of the problem, you can rest assured that the technicians at the Borivali service center will do a top-notch job.

    ReplyDelete
  29. Value assignment help act as a tuition teacher and guides students looking for online academic assistance for assignments, homework, and essay writing services. contact valueassignmenthelp.com they provide plagiarism free content. Value assignment help is the best solution for you. They are best known for delivering assignment help services to students without having to break the bank. WhatsApp no.: +91-9872003804, +61-413228507.

    ReplyDelete
  30. Nice Post Your content is very inspiring and appreciating I really like it

    Launch Date
    The new Maruti Suzuki Vitara Brezza 2022 is expected to be launched sometime in June 2022.

    Commission
    Under the hood, the new Brezza 2022 is expected to be powered by the same 1.5-liter K- Series petrol engine as the current-generation model, which produces 103 horsepower and 138 Nm of torque. The five-speed manual transmission and the four-speed automatic torque converter will also likely continue.

    Brezza 2022

    ReplyDelete
  31. In addition, All Places Map is helpful for students as well to find New York Zip Code. It is one of the best study abroad apps for students who are planning to study abroad. You can find all necessary information about the country you are going to study in. You can find information about universities, housing, visa process, food, culture, transportation and everything.

    ReplyDelete

Ain't getting any visitors!
Please Share and Bookmark posts.

Tags

: (1) 18F2550 (1) 36KHz (3) and (1) arduino (1) Based (1) battery (1) Bipolar (1) Blinking (1) blinks (1) Bluetooth (1) bluetooth device interfacing (1) bluetooth module (1) button (1) circuit (1) clock (1) control (1) crystal oscillator (3) Db9 (1) DC Motor (2) digital (2) Digital Voting Machine (1) digital voting machine using pic (1) display (2) DS1307 (1) electronic (1) embedded c programming tutorial (11) embedded c tutorial (11) experiment kit (4) external interrupt (4) flash (1) flashing (1) Gas Leakage detector (1) HC-06 (1) home (1) how (1) How to (10) i2c tutorial (1) in (1) indicator (1) infrared Connection (3) interface (8) interfacing (3) Interrupt (3) Introduction (1) IR Connection (3) IR Receiver (4) IR Transmitter (4) key pad (1) keyboard (1) keypad (1) lavel (1) Lcd 16x2 (2) lcd 2x16 (2) led (1) lm35 (2) LPG (1) machine (1) make (1) Make bootloader (1) making (1) matrix (1) max232 (1) membrane keyboard (2) meter (2) Micocontroller (1) microchip (4) microchip pic (2) microchips (3) microcontroller (9) microcontroller based (3) microcontroller programming (3) Microcontroller Project (4) Microcontroller Projects (1) microcontroller_project (2) microcontrollers (4) Microprocessor (2) mikroC (5) mikroc code to start and stopstart and stop dc motor (1) mikroc pro for pic (2) Motion detector (1) MQ-9 Gas Sensor (1) musical (1) NEC Protocol (4) pcb (5) PIC (3) pic controller (11) pic microcontroller (11) pic microcontroller tutorial (11) pic programming (1) pic programming in c (12) pic proteus (1) Pic Tutorial (12) pic18 (2) pic18f2550 (11) picmicrocontroller (4) picRFモジュール (1) PIR Motion Sensor (1) printed circuit board (1) proteus (6) pulse width modulation (1) push (1) push button (1) PWM (1) real (1) rf transmitter (3) Rs 232 (1) Rs232 (1) scroll (1) scrolling (1) Serial communication (1) Serial Connection (1) Serial Port (1) serial port rs232 (1) Servo Motembedded c programming tutorial (1) simulation (2) Soil Moisture Meter (1) speed control (1) step by step (7) step bystep (1) Stepper Motor (2) text (2) Thief Detector (1) time (1) timer (4) timer0 (4) tone (1) TSOP38236 Receiver (4) tutorial (2) Unipolar (1) USART Connection (1) USB (1) usb 1.0 (1) USB bootloadere (1) USB HID (1) using (9) voltmeter (1) voting (1) water level indicator (3) with (2) work (1)

Traffic Feed


Live Traffic Feed
Visitor Tracking

Leave Your Message Here

Name

Email *

Message *

Like on Facebook