Thanks again @PCBWay for sponsoring my project. PCBWay You can have your PCB boards produced for 5$. And it provides all kinds of printing and assembly services.
PCBWay: https://www.pcbway.com/
PCBWay+ my profile: https://www.pcbway.com/project/member/?bmbno=188E1A91-204D-4
Hello, today I am here with an interesting project in this project:
What is Mechanical Switch?
Mechanical switches are a type of switch often used in electronic devices. These switches are used to transmit or interrupt electrical signals. Mechanical switches can improve the performance of electronic devices by providing more accurate control over electrical current.
Mechanical switches are a type of switch that can switch between two states of electrical current being on or off. These switches usually determine the position of the switch using a spring or an insulating material. In spring mechanical switches, the spring forces the switch to close and a force is applied to open the switch. In mechanical switches using insulating material, the switch position is determined by electromagnetic interaction or physical contact.
The working principle of mechanical switches may differ depending on their different types. For example, in spring mechanical switches, the closing of the switch occurs due to spring pressure, while in mechanical switches using insulating material, the position of the switch is determined by electromagnetic interaction or physical contact.
Now let me tell you about my card:This project aims to create a keyboard using mechanical switches. The Arduino Pro Micro reads the keyboard layout and the state of the mechanical switches, making keyboard inputs to the computer. In addition, customized keyboard functions can be created according to the keyboard layout and the state of the switches.
Necessary materials:
Arduino Pro Micro
Mechanical Switches (10)
10k resistor (10 grains)
USB cable
Keyboard key caps (optional)
Programming:
Arduino IDE can be used for programming. The program will read the states of the switches and contain the codes for keyboard input to the computer. Customized keyboard functions can also be created based on the keyboard layout and the state of the switches. For example, one switch can simulate the "CTRL" key, the other the "ALT" key, and the other the "DELETE" key.
Mechanism:
The keyboard layout is designed according to the way the switches are connected. The Arduino Pro Micro continuously reads the status of the switches and makes keyboard inputs to the computer. When any switch is pressed, the corresponding ASCII character is sent to the computer. In addition, customized keyboard functions can be created according to the keyboard layout and the state of the switches. For example, one switch can simulate the "CTRL" key, the other the "ALT" key, and the other the "DELETE" key. These customized keyboard functions can be useful for certain applications or games.
This project is a great opportunity to understand how a keyboard works, learn to use mechanical switches, and create keyboard functions with Arduino. The detailed implementation of this project can be of great benefit to those who want to create customized keyboard functions.
The materials required to implement this project are quite inexpensive and can be found in almost any electronics store. Also, a good knowledge of electronics and programming is required to complete this project. However, this project provides a great learning opportunity for those who want to improve their electronics and programming skills.
Code:#include <Keyboard.h>
const int ROWS = 2; // 2 satır mekanik switchler
const int COLS = 5; // 5 sütun mekanik switchler
// Mekanik switchlerin pinleri
const int rowPins[ROWS] = {2, 3};
const int colPins[COLS] = {4, 5, 6, 7, 8};
// Klavye tuşlarının düzenlenmesi
char keys[ROWS][COLS] = {
{'1', '2', '3', '4', '5'},
{'6', '7', '8', '9', '0'}
};
void setup() {
// Mekanik switchlerin pinleri giriş olarak ayarlanıyor
for (int i = 0; i < ROWS; i++) {
pinMode(rowPins[i], INPUT_PULLUP);
}
for (int i = 0; i < COLS; i++) {
pinMode(colPins[i], INPUT_PULLUP);
}
// Klavye başlatılıyor
Keyboard.begin();
}
void loop() {
// Tüm sütunlar taranıyor
for (int col = 0; col < COLS; col++) {
// Sütun pinleri çıkış olarak ayarlanıyor ve LOW seviyesine getiriliyor
pinMode(colPins[col], OUTPUT);
digitalWrite(colPins[col], LOW);
// Tüm satırlar taranıyor
for (int row = 0; row < ROWS; row++) {
// Mekanik switchin durumu okunuyor
if (digitalRead(rowPins[row]) == LOW) {
// Klavye tuşuna basıldığında, klavyeye tuşun harfi gönderiliyor
Keyboard.write(keys[row][col]);
// Tuş serbest bırakıldığında, klavyeden harfin gönderimi durduruluyor
while (digitalRead(rowPins[row]) == LOW) {
delay(10);
}
}
}
// Sütun pinleri tekrar giriş olarak ayarlanıyor
pinMode(colPins[col], INPUT_PULLUP);
}
}
After uploading this sample code to Arduino Pro Micro, you can use mechanical switches as keyboards. You can rearrange the keyboard keys any way you want, but don't forget to update the "keys" array. You also need to have sufficient programming knowledge to read and understand code.
Some disadvantages of this keyboard project using mechanical switches and Arduino Pro Micro:- Longevity of mechanical switches: The lifespan of mechanical switches depends on the frequency of use of the keyboard and the quality of mechanical switches. Cheap or poor quality mechanical switches can break down or have trouble with keystrokes after less use.
- High cost: Arduino Pro Micro and mechanical switches can be a little more expensive to make a keyboard. Especially if you want to build a keyboard with many keys, the cost can add up quickly.
- High power consumption: Arduino Pro Micro will consume power even when the keyboard is not used. This can be a significant drawback, especially if you want to make a battery-powered keyboard.
- Lack of built-in keyboard features: The keyboard you will make in this project may not have all the features found on a computer keyboard. For example, you cannot provide a multimedia keyboard or a keyboard backlight.
- These disadvantages are factors to consider for those who want to make a keyboard. However, making a mechanical switch keyboard, especially a customized one, can be an enjoyable experience.
The first purpose of this board is designed to automatically write commands in PCB designs, but whatever you code to the Arduino Pro micro on it will be, so you can code and run it in any way you want, whether it is a game or a job. The rest is up to your imagination. You plug in a screen and play games. You plug in a bigger screen and use it for different tasks. So as I said, it all depends on your imagination, I made the project and shared the files. Make changes on it, BUT DON'T BE THE SAME, DIFFERENT IDEAS AND PROJECTS DEVELOP THIS SECTOR. Never forget this.
More to come, stay tuned.
Thanks for reading this far.
Many thanks to PCBWay for sponsoring me
Comments
Please log in or sign up to comment.