Arduino + PS/2 Keyboard Controlled LED Flasher

Introduction: Arduino + PS/2 Keyboard Controlled LED Flasher

About: My life is Not only Writing Lines of Codes, But gaining something good. I'm simple in physical world but Very complex in ICT word.

Hi all, It's another Hack with Arduino to be used with PS/2 Keyboard to Control an LED Flasher.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Parts

  • Arduino
  • LED
  • 470 ohm Resistor
  • PS/2 Keyboard
  • PS/2 Keyboard connector

Step 2: Connection

Connect the Arduino to Keyboard.There are 4 wires coming from the keyboard and their connections to arduino Digital pins are as follows.

  • 5V :- Arduino 5V out
  • Ground :- Arduino GND
  • Clock :- Arduino Pin 3
  • Data :- Arduino Pin 8

Connect LED to Arduino Pin 9.

Step 3: Code

First Include this library to Arduino (Sketch > Add file) < PS2Keyboard.h>

<p>#include < PS2Keyboard.h><br>const int DataPin = 8;
const int IRQpin =  3;
char c;
PS2Keyboard keyboard;
int led = 9;           // the pin that the LED is attached to
void setup() {  
  delay(1000);
  keyboard.begin(DataPin, IRQpin);
  pinMode(led, OUTPUT);
}
void loop() {
  {
  if (keyboard.available()) {    
    c = keyboard.read()*25;   
    analogWrite(led, c);
  }         
}}</p>

Step 4: Finished - Working Video

Now power the arduino and Pess any number on keyboard.

Ex:- no. 7

See how the LED Flashing changed.

Be the First to Share

    Recommendations

    • Trash to Treasure Contest

      Trash to Treasure Contest
    • Raspberry Pi Contest 2020

      Raspberry Pi Contest 2020
    • Wearables Contest

      Wearables Contest

    Discussions