element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Personal Blogs
  • Community Hub
  • More
Personal Blogs
NexGen Flight Simuator How to use a PS/2 Keyboard Encoder with interrupts.
  • Blog
  • Documents
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: phoenixcomm
  • Date Created: 10 May 2024 2:45 AM Date Created
  • Views 616 views
  • Likes 6 likes
  • Comments 3 comments
  • flight simulator
  • nexgen
  • How To
  • interrupts
  • ps2_keyboard_encoder
  • arduino
Related
Recommended

How to use a PS/2 Keyboard Encoder with interrupts.

phoenixcomm
phoenixcomm
10 May 2024

imageHow many PS/2 keyboards do you have? More than one, I'd bet. Well, stop trying to hang them on your tree, and use them not the whole thing just the encoder. BTW that's the little black thing on the rear. 

image
1----DATA
3----GROUND
4----+5 V DC at 275 ma
5----CLLK

Of the six pins, we will only use four (4) of them. So what do we need? This will use an Arduino, and get this library:
Reference > Libraries > Ps2keyboard
This library is compatible with all architectures and boards.

image
image

Lib Code My Code   this code has NOT been tested. 

PS2Keyboard keyboard;
void setup() { delay(1000); keyboard.begin(DataPin, IRQpin);
Serial.begin(9600);
Serial.println("Keyboard Test:"); }
void loop() { if (keyboard.available()) { // read the next key char c = keyboard.read(); // check for some of the special keys
if (c == PS2_ENTER) { Serial.println(); }
else if (c == PS2_TAB) { Serial.print("[Tab]"); } else if (c == PS2_ESC) { Serial.print("[ESC]"); }
else if (c == PS2_PAGEDOWN) { Serial.print("[PgDn]"); }
else if (c == PS2_PAGEUP) { Serial.print("[PgUp]"); }
else if (c == PS2_LEFTARROW) { Serial.print("[Left]"); }
else if (c == PS2_RIGHTARROW) { Serial.print("[Right]"); }
else if (c == PS2_UPARROW) { Serial.print("[Up]"); }
else if (c == PS2_DOWNARROW) { Serial.print("[Down]"); }
else if (c == PS2_DELETE) { Serial.print("[Del]"); }
else { // otherwise, just print all normal characters Serial.print(c); } } }

#include const int DataPin = 8;
const int IRQpin = 5;

void setup() { delay(1000); keyboard.begin(DataPin, IRQpin);
attachInterrupt(digitalPinToInterrupt(1), handleInterrupt, RISING);
Serial.begin(9600);}
//IRQ

void IRQkey(if (keyboard.available()) {
char c = keyboard.read(); // c is a global
int charFlag = 1;}

int keyProcess(){
charFlag = 0;
// more code
return (something)

  • Sign in to reply
  • DAB
    DAB over 1 year ago

    Very interesting.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • phoenixcomm
    phoenixcomm over 1 year ago in reply to scottiebabe

     scottiebabe   It's a nice overview. Watch what's next!

    imageDeciphering Mystery Keyboards  I could not help myself.. and I did use it..in my Master Caution Panel and the CDU ASN=1252 ~~ Cris -- Wopie lots of wire!! below is my picture.. 

    image

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • scottiebabe
    scottiebabe over 1 year ago

    Neat idea repurposing an encoder IC, thanks for the tangent 

    kbd.news/A-brief-history-of-keyboard-encoding-2199.html

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube