Cov txheej txheem:

Arduino PS/2 rau USB Adapter: 7 Kauj Ruam (nrog Duab)
Arduino PS/2 rau USB Adapter: 7 Kauj Ruam (nrog Duab)

Video: Arduino PS/2 rau USB Adapter: 7 Kauj Ruam (nrog Duab)

Video: Arduino PS/2 rau USB Adapter: 7 Kauj Ruam (nrog Duab)
Video: Ich finde Sie sympathisch 🤭#davidbost #motorrad #gehtsteil #shorts 2024, Kaum ib hlis
Anonim
Arduino PS/2 rau USB Adapter
Arduino PS/2 rau USB Adapter
Arduino PS/2 rau USB Adapter
Arduino PS/2 rau USB Adapter

Koj puas tau xav siv koj li qub PS/2 Keyboard nrog koj lub khoos phis tawj lossis lub khoos phis tawj tshiab thiab pom tias lawv tsis muaj PS/2 chaw nres nkoj ntxiv lawm? Thiab tom qab ntawd ntau dua li mus yuav PS/2 pheej yig rau USB Adapter zoo li tus neeg ib txwm yuav ua, xav siv koj li Arduino ua PS/2 rau USB Adapter. Tom qab ntawd koj tau los rau qhov chaw raug:)

Kev ceeb toom ncaj ncees ua ntej peb nkag mus rau nws. Thaum koj siv koj li UNO/Mega ua USB-HID ntaus ntawv (Tsis txwv rau cov keyboard, nws tuaj yeem yog nas, joystick, thiab lwm yam) koj yuav tso nws cov haujlwm ib ntus li Arduino ib ntus. Los ntawm qhov kuv txhais tau tias koj siv tsis tau Kev Sib Txuas Lus thiab koj tsis tuaj yeem rov tsim dua nws ntawm USB. Qhov no yog vim tias peb yuav dhau-sau cov firmware ntawm nws USB interface nti (tus txiv leej tub nyob ze ntawm USB chaw nres nkoj Atmega8U2 thiab 16U2 nyob ntawm qhov kho dua tshiab). Tab sis tsis txhob txhawj xeeb koj tsis tuaj yeem ua cib koj li UNO/Mega los ntawm kev ua qhov no nws ib txwm thim rov qab.

Tsis tas li los ntawm txhua lub sijhawm yog tias koj muaj Arduino uas twb muaj lub peev xwm USB-HID (Arduino Pro Micro lossis Leonardo, thiab lwm yam ua kev tshawb fawb hauv google) koj tuaj yeem hnov qab cov lus qhia no puas tau muaj nyob ncaj qha ntawm no kom cawm koj tus kheej los ntawm lub ntiaj teb muaj teeb meem, tsuas yog tso dag

Khoom siv

  • Kho vajtse

    • Arduino UNO lossis Mega
    • PS/2 Keyboard
    • Xaiv qhov ntxiv Arduino lossis Txhua yam ntawm USB programmer (USBasp, thiab lwm yam) tuaj yeem ua ke.
  • Software

    • Atmel FLIP
    • PS2KeyAdvanced lub tsev qiv ntawv rau Arduino IDE

Kauj Ruam 1: Kev teeb tsa thiab teeb tsa

Kev teeb tsa thiab teeb tsa
Kev teeb tsa thiab teeb tsa
Kev teeb tsa thiab teeb tsa
Kev teeb tsa thiab teeb tsa
Kev teeb tsa thiab teeb tsa
Kev teeb tsa thiab teeb tsa
Kev teeb tsa thiab teeb tsa
Kev teeb tsa thiab teeb tsa

Nyob ntawm qhov xwm txheej koj tuaj yeem nrhiav pom lub rooj sib tsoo tawg lossis khaws cov chaw nres nkoj qub los ntawm lub niam ntawv (kuv sim thib 2) lossis yog tias koj muaj kev xav tsis zoo tshwj xeeb koj tuaj yeem txiav cov kab liab liab tag nrho thiab nthuav tawm 4 xov hlau (kuv sim thib 1) thiab txuas lawv mus rau UNO.

Keyboard _Arduino

+5V (VCC) _+5V

GROUND_GND

CLOCK_PIN 2 **

DATA _ PIN3*

*Koj tuaj yeem hloov DATA tus pin rau yam koj xav tau tab sis nco ntsoov hloov kho daim duab.

** CLOCK yuav tsum txuas nrog tus pin cuam tshuam ntawm Arduino uas tsuas tuaj yeem yog tus lej PIN 2 lossis 3 (nco ntsoov hloov kho qhov kos duab) ntawm UNO. Yog xav paub ntxiv thiab teeb tsa pawg thawj coj sib txawv koj tuaj yeem tshawb xyuas tshooj lus ntawm PS2KeyAdvanced lub tsev qiv ntawv piv txwv.

Kauj ruam 2: Xeem Keyboard

Ua ntej koj mus txhua txhais tes ntawm lub lawj xub ua kom ntseeg tau tias txhua yam ua haujlwm ntawm cov keyboard thiab tsev qiv ntawv.

Ntawm no kuv tau txuas qhov hloov kho ntawm SimpleTest.ino los ntawm PS2KeyAdvanced lub tsev qiv ntawv piv txwv nrog hloov kho lub moos thiab cov ntaub ntawv pins thiab tseem yog "ua" thiab "tawg" sawv cev. Nov yog qee qhov kev piav qhia rau cov zis.

  • Qhov no "ua" thiab "tawg" scancode system thiab "Code" uas yog qhov cais (c & 0xFF) scancode ntawm tus yuam sij-nias lossis tus yuam sij-tso ua lub luag haujlwm tseem ceeb hauv PS/2 rau USB hloov dua siab tshiab thiab kuv xav kom koj kawm lwm 2 qhov piv txwv uas los nrog lub tsev qiv ntawv kom nkag siab zoo dua yog tias koj tab tom npaj txhim kho lossis hloov pauv (rov ua cov yuam sij rau cov txheej txheem sib txawv) qhov kos duab zaum kawg. Tsis tas li koj tuaj yeem tau txais daim ntawv teev npe ntawm PS/2 scancodes los ntawm lub tsev qiv ntawv los ntawm kev qhib 'PS2KeyAdvanced.h' lossis 'PS2KeyCode.h' cov ntaub ntawv los ntawm '\ Documents / Arduino / libraries / PS2KeyAdvanced / src \'
  • "Cov xwm txheej khoom" hais txog hloov kho cov yuam sij (Ctrl, Alt, Windows, Shift/Caps) thiab koj yuav pom tias nrog txhua qhov hloov kho qhov tseem ceeb ntxiv, tus nqi no hloov pauv thaum lub ntsiab "Code" ntawm ib txwm (tsis hloov kho) qhov tseem ceeb tsis hloov pauv. Tab sis hauv qhov kev kos duab zaum kawg kuv tau tsis quav ntsej txoj hauv kev no thiab siv cov hloov kho no ua cov yuam sij yooj yim-nias (Koj yuav pom tias cov yuam sij hloov kho no tseem muaj "ua" thiab "tsoo" scancode ywj pheej los ntawm cov yuam sij ib txwm muaj los yog tsis muaj ntau tus yuam sij raug nias.) vim nws ua tej yam yooj yim dua nrog USB-HID raws tu qauv.

Kauj Ruam 3: PS/2 rau USB Hloov Ua Ntej Ua Ntej

Ua ntej hloov kho Atmega8U2 lossis 16U2 (UNO Rev3) txhawm rau txheeb xyuas peb Arduino ua USB keyboard peb yuav tsum ua kom ntseeg tau tias txhua yam khoom hloov pauv tau ua haujlwm raug thiab qhov kawg daim duab kawg tau rub tawm lossis lwm yam nws yuav yog qhov mob loj kom khaws ntau dua firmware dua ib zaug ntxiv ntawm Thawj thiab USB-keyboard hex cov ntaub ntawv tsuas yog li koj tuaj yeem tso qhov kos duab raug. Qhov no dhau los ua qhov tseeb tshwj xeeb yog tias koj tsis muaj lwm tus programmer zoo li USBasp lossis lwm tus Arduino los siv ua ISP. Yog li ntawm no peb yuav tshaj tawm 'DEBUG' version ntawm qhov kev kos duab zaum kawg nrog rau tib neeg nyeem tau (los ntawm cov saib hauv qab) los ntsuas yam tawm.

Cov zis uas koj pom yuav raug teeb tsa zoo li no thaum txhua tus yuam sij raug tso tawm, 00 00 00 00 00 00 00 00

Nov yog cov lus piav qhia yooj yim rau qhov kev cia siab tso tawm,

Rau txhua qhov tshiab ntau yam hloov kho qhov tseem ceeb-nias koj yuav tsum tau txais kab ntawv tshiab nrog cov txiaj ntsig sib txawv rau 'xx'. Thaum kawg thaum koj tso tawm txhua qhov hloov kho cov yuam sij 'xx' yuav tsum dhau 00

xxxxxxxxxxxxxx 0

Rau txhua qhov tshiab ntau qhov tseem ceeb-nias (piv txwv li peb yuav nias ob qhov yuam kev hypothetical a, key b thiab key c nrog tus nqi 'xx', 'yy' thiab 'zz' hauv qhov kev txiav txim) koj yuav tsum tau txais txuas ntxiv mus (tsis tas yuav tsum tau ua) newlines zoo li no,

00 00 xx yy zz 00 00 00

thaum koj tsuas tso qhov tseem ceeb b tso tawm yuav tsum hloov mus rau,

00 00 xx 00 zz 00 00 00 Nws

thiab yog tias koj nias tus yuam sij tshiab d nrog tus nqi 'nn' yam tsis tso tus yuam sij lossis tus yuam sij b koj cov zis yuav tsum hloov mus,

00 00 xx nn zz 00 00 00

thiab thaum kawg rov qab los rau qhov no thaum txhua tus yuam sij raug tso tawm,

00 00 00 00 00 00 00 00

thiab kawg yog tias koj nias lub Caps Lock, Num Lock lossis Scroll Lock koj yuav tsum tau txais qee yam zoo li no nrog ntau kab nyob rau tib lub sijhawm,

00 00 xx 00 00 00 00 00 00 Nws

00 00 00 00 00 00 00 00

00 00 00 00 00 00 00 00

Yog tias txhua yam ntawm no tshwm sim koj yog xim kub mus ntxiv!

Kauj Ruam 4: Piav Qhia

Kev piav qhia
Kev piav qhia
Kev piav qhia
Kev piav qhia

Yog tias koj nyiam koj tuaj yeem hla cov kauj ruam no. Qhov no tsuas yog kev piav qhia rau cov txiaj ntsig dhau los. Cov zis 8 bytes array uas koj pom tau muab ua qauv raws li daim duab saum toj no. 1 Koj tuaj yeem kawm paub ntau ntxiv txog qhov no thiab tseem yuav ua li cas tus hloov kho cov xwm txheej byte tau sau los ntawm wiki no txog USB-HID. Yeej qhov kuv tus lej ua yog txhua lub sijhawm tus yuam sij tshiab raug nias (PS/2 raws tu qauv hais txog qhov no raws li 'ua') nws mus los dhau 6 bytes kawg ntawm cov kab uas tau siv rau qhov tseem ceeb-nias, thiab sau thawj zaug npliag byte nws pom nrog qhov cuam tshuam 'HID scancode' (Qhia zoo li hauv daim duab 2 Tsis tas li ntawd koj tuaj yeem pom cov npe tiav los ntawm daim ntawv PDF txuas) rau qhov tau txais 'PS/2 scancode'. Thiab thaum kawg thaum tus yuam sij cuam tshuam raug tso tawm (PS/2 raws tu qauv hais txog qhov no 'tawg') cov cai yuav hloov pauv mus rau tam sim no byte array thiab tshem tawm tsuas yog cov byte cuam tshuam.

Yog tias koj ua raws li no thiab tseem yog tias koj nyeem nplooj ntawv wiki koj yuav pom tias muaj teeb meem me me hauv txoj kev no, ib txwm thaum tus yuam sij raug tso tawm, hauv HID raws tu qauv qhov seem bytes tau rov teeb tsa raws li kom tshem tau cov khoob khoob nruab nrab ntawm qhov uas tsis yog khoob bytes. Tab sis rau qee qhov laj thawj tsis hais txog pes tsawg txoj hauv kev kuv tau sim kuv tsis tuaj yeem ua nws raws li lub hom phiaj yam tsis tau ua yuam kev tshem tawm qhov tsis xav tau bytes rau cov yuam sij ib yam nkaus. Yog tias koj tuaj yeem txhim kho qhov no kom nws ua haujlwm thov tawm lus. Txawm hais tias nyob rau hnub kawg qhov teeb meem no tsis cuam tshuam rau kev ua haujlwm ntawm cov keyboard ntev li Arduino tseem sau npe txhua tus yuam sij-nias tsis hais lawv qhov kev txiav txim nias (Uas tsis cuam tshuam dab tsi hauv kev siv tau).

Kauj Ruam 5: Tshaj Tawm Qhov Kawg Kawg

Yog li ua ntej koj thaum kawg hloov kho qhov firmware ntawm Atmega8U2 lossis 16U2 (UNO Rev3) txhawm rau txheeb xyuas peb Arduino ua USB keyboard peb yuav tsum tso qhov kawg Sketch. Tom qab koj rub tawm qhov no, yog tias koj mus rau tus saib xyuas lub luag haujlwm koj yuav pom nws luam tawm cov khib nyiab nrog txhua tus yuam sij tshiab nias qhov no yog lub cim zoo uas txhua yam tau ua haujlwm raws li lub hom phiaj thiab peb tuaj yeem mus rau kauj ruam kawg. YAJ !!!

Kauj ruam 6: Hloov kho Firmware

Thaum kawg koj tuaj yeem hloov kho lub firmware ntawm koj Arduino txhawm rau sau npe nws li USB keyboard. Txog qhov no kuv yuav tsis mus rau hauv cov ntsiab lus ntau npaum li nws yuav ua rau cov lus qhia no ntev dhau.

  1. Ua raws phau ntawv qhia no los ntawm arduino.cc txog 'Hloov Kho Atmega8U2 thiab 16U2 ntawm Uno lossis Mega2560 siv DFU' tab sis ntau dua li siv 'Arduino-usbserial-uno.hex' siv qhov txuas 'Arduino-keyboard-0.3.hex'
  2. Hauv FLIP nco ntsoov xaiv lub hom phiaj ntaus ntawv li Atmega8U2 lossis 16U2 nyob ntawm koj Arduino thiab, los ntawm kev xaiv qhov nruab nrab kev sib txuas lus xaiv USB thiab thaum kawg thauj cov ntaub ntawv hex kom raug ua ntej xaiv khiav.
  3. Yog tias koj tau khiav mus rau tus tsav tsheb yuam kev, mus rau tus thawj tswj lub cuab yeej windows thiab xaiv tshawb rau tus tsav tsheb tsis paub nyob hauv kab ntawv teeb tsa ntawm FLIP 'Program Program Files (x86) Atmel \'
  4. Yog tias koj tau ua yuam kev thaum hloov kho lub firmware los ntawm FLIP ntau zaus, kaw FLIP thiab khiav 'Pib dua Nyiam' los ntawm 'Start menu / FLIP \' thiab tom qab ntawd rov pib FLIP thiab ua cov txheej txheem teeb tsa ua ntej sim qhov no feem ntau ua haujlwm rau kuv.
  5. Yog tias koj xav rov kho koj Arduino rau nws lub xeev qub tsuas yog ua raws cov lus qhia arduino.cc saum toj no rau tsab ntawv yam tsis siv daim ntawv hex no.

Kauj Ruam 7: Txaus siab rau ……

Txaus siab rau ……
Txaus siab rau ……

Tam sim no txaus siab rau koj qhov hloov pauv PS/2 tshiab rau USB keyboard…. PS Cov Lus Qhia no tau sau tag nrho los ntawm sab nraud PS/2 keyboard txuas nrog kuv lub khoos phis tawj los ntawm Arduino:)

Pom zoo: