Led keyboard not working

Recently I bought an Arduino, and wanted to try a project where pressing a key on a PS/2 keyboard makes a specific LED light up. However when I went to run the project this error message appeared.

Arduino: 1.8.12 (Windows , Board: "Arduino Uno")

In file included from C:\Users\Darge\Downloads\KeyboardLights\KeyboardLights.ino:2:0:

C:\Users\People\Darge\Documents\Arduino\libraries\FastLED/FastLED.h:14:21: note: #pragma message: FastLED version 3.003.003

pragma message "FastLED version 3.003.003"

^~~~~~~~~~~~~~~~~~~~~~~~~~~

C:\Users\Darge\OneDrive\Documents\Arduino\libraries\PS2Keyboard\PS2Keyboard.cpp:265:53: warning: multi-character character constant [-Wmultichar]

0 /CapsLock/, 0 /Rshift/, PS2_ENTER /Enter/, '¤', 0, '#', 0, 0,

^~~~

C:\Users\Darge\OneDrive\Documents\Arduino\libraries\PS2Keyboard\PS2Keyboard.cpp:271:1: warning: narrowing conversion of '-15708' from 'int' to 'uint8_t {aka unsigned char}' inside { } [-Wnarrowing]

};

^

C:\Users\Darge\OneDrive\Documents\Arduino\libraries\PS2Keyboard\PS2Keyboard.cpp:271:1: warning: large integer implicitly truncated to unsigned type [-Woverflow]

Sketch uses 6504 bytes (20%) of program storage space. Maximum is 32256 bytes.
Global variables use 537 bytes (26%) of dynamic memory, leaving 1511 bytes for local variables. Maximum is 2048 bytes.
An error occurred while uploading the sketch
avrdude: ser_open(): can't open device "\.\COM6": The system cannot find the file specified.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

I do not understand what most of this means (Wnarrowing, Woverflow, etc) I am following a tutorial and did not write the code for this project. I am new to programming in general so any advice would be extremely helpful. :slight_smile:

Could you post your code here

Sure!

#include “FastLED.h”
#include <PS2Keyboard.h>

#define NUM_LEDS 50
#define DATA_PIN 7

const int DataPin = 8;
const int IRQpin = 3;

PS2Keyboard keyboard;
CRGB leds[NUM_LEDS];

void setup() {
delay(1000);
keyboard.begin(DataPin, IRQpin);
Serial.begin(9600);

FastLED.addLeds<WS2811, DATA_PIN, RGB>(leds, NUM_LEDS);
}

void clear(){
for (int i = 0; i < NUM_LEDS; i++)
{
leds = CRGB::Black;

  • }*

  • FastLED.show();*
    }
    void loop() {

  • char c;*

  • if (keyboard.available()) { *

  • // read the next key*

  • c = keyboard.read();*

  • }*

  • clear();*

  • switch (c) {*

  • case ‘a’:*

  • leds[0] = CRGB::White;*

  • break;*

  • case ‘b’:*

  • leds[1] = CRGB::Blue;*

  • break;*

  • case ‘c’:*

  • leds[2] = CRGB::Red;*

  • break;*

  • case ‘d’:*

  • leds[3] = CRGB::White;*

  • break;*

  • case ‘e’:*

  • leds[4] = CRGB::Blue;*

  • break;*

  • case ‘f’:*

  • leds[5] = CRGB::Yellow;*

  • break;*

  • case ‘g’:*

  • leds[6] = CRGB::Red;*

  • break;*

  • case ‘h’:*

  • leds[7] = CRGB::Blue;*

  • break;*

  • case ‘i’:*

  • leds[17] = CRGB::Blue;*

  • break;*

  • case ‘j’:*

  • leds[16] = CRGB::Red;*

  • break;*

  • case ‘k’:*

  • leds[15] = CRGB::Blue;*

  • break;*

  • case ‘l’:*

  • leds[14] = CRGB::White;*

  • break;*

  • case ‘m’:*

  • leds[13] = CRGB::Yellow;*

  • break;*

  • case ‘n’:*

  • leds[12] = CRGB::Red;*

  • break;*

  • case ‘o’:*

  • leds[11] = CRGB::Red;*

  • break;*

  • case ‘p’:*

  • leds[10] = CRGB::White;*

  • break;*

  • case ‘q’:*

  • leds[9] = CRGB::Red;*

  • break;*

  • case ‘r’:*

  • leds[23] = CRGB::White;*

  • break;*

  • case ‘s’:*

  • leds[24] = CRGB::White;*

  • break;*

  • case ‘t’:*

  • leds[25] = CRGB::Yellow;*

  • break;*

  • case ‘u’:*

  • leds[26] = CRGB::Blue;*

  • break;*

  • case ‘v’:*

  • leds[27] = CRGB::Red;*

  • break;*

  • case ‘w’:*

  • leds[28] = CRGB::Blue;*

  • break;*

  • case ‘x’:*

  • leds[29] = CRGB::Yellow;*

  • break;*

  • case ‘y’:*

  • leds[30] = CRGB::Red;*

  • break;*

  • case ‘z’:*

  • leds[31] = CRGB::Red;*

  • break;*

  • }*

  • FastLED.show();*

  • delay(1000);*

  • clear();*

  • delay(500);*
    }

Have you tested the keyboard and LEDs separately, with independent sketches?

Not yet. I should find some code to test each.

The example sketches that come with the libraries would be a good place to start. You can even access those from the IDE menu, once they are installed.

Ignore the first lot of “errors”. They are in fact just warnings, and haven’t stopped your code compiling.
As they are warnings from the external libraries, and not your own code, you shouldn’t be too bothered trying to fix them at this stage.
Granted, supplied libraries should ideally compile without warnings, but it’s not your fault or problem to fix with your main sketch.

You main problem seems to be completely unrelated and due to…

avrdude: ser_open(): can’t open device “\.\COM6”: The system cannot find the file specified.

Which implies a problem communication with the Arduino because the serial port is not working.

You still have the Arduino connected to the PC right?
You not somehow trying to fudge together two devices (the Arduino and a keyboard) onto the same serial/USB port on the Arduino end are you?

Have you uploaded sketches to this Arduino from this PC before?
What type of Arduino is it?
What is showing, if anything, in Windows Device Manager under COM/LPT ports section?
What is showing in the Arduino IDE under Tools → Port?
Try restarting the IDE.

When posting code include it in code tags please as per the posting guidelines: [​code][​/code]
You can insert these automatically with the </> button on the toolbar.

Ok, I messed around with the “Com6” error and I found that my arduino IDE says that the port is set to COM5.
Is this causing the problem? I tried running test code on the keyboard and came up with the same error. Another possibility is that I might have the pins plugged into the wrong places. I am using a PS/2 adapter that is connected to the keyboard on one side, and on the other I cut off the end and soldered the 4 wires onto jumper cables for the arduino. Here are the pins I have plugged in currently.

Red wire - pin 3

Black wire - 5v

Dark pink wire - pin 7

Light pink wire - pin 8

Please let me know if I made any obvious mistakes while wiring this, and thank you to everyone who is helping me with this. :slight_smile:

messed around with the "Com6" error and I found that my arduino IDE says that the port is set to COM5.

That’s definitely not right. Message in the window should match port selected in IDE.
Which COM port is the Arduino actually on? Fire up Windows device manager and plug in the Arduino. Which COM port appears when you do that?

If you are still getting COM errors when uploading you need to fix them first - Back to basics
Unplug everything from the Arduino except the connection to your PC
Load up the blinky test sketch in the IDE
Try and upload it
Does it upload successfully?
If not, check in device manager and make sure COM port is showing, correct drivers are loaded, correct COM and board type selected in IDE, etc, etc

I have been using an "Elegoo uno R3" that came in a starter kit I ordered recently. However, I also ordered a regular arduino uno and I tried switching to that board and immediately noticed that the COM port switched to 6. However when I try running any programs the same error appears, but this time stating that the system cannot open COM5. When I opened my IDE it notified me that my boards could be updated but the window dissapeared quickly. Will updating them do anything?

Or could the wires I soldered be somehow shorting and causing a problem?

I've deleted your other cross-posts @twg123.

Cross-posting is against the rules of the forum. The reason is that duplicate posts can waste the time of the people trying to help. Someone might spend 15 minutes (or more) writing a detailed answer on this topic, without knowing that someone else already did the same in the other topic.

Repeated cross-posting will result in a suspension from the forum.

In the future, please take some time to pick the forum board that best suits the topic of your question and then only post once to that forum board. This is basic forum etiquette, as explained in the sticky "How to use this forum - please read." post you will find at the top of every forum board. It contains a lot of other useful information. Please read it.

Thanks in advance for your cooperation.

Ok sorry! I fixed the com error by plugging my arduino into another usb port. But the keyboard still has no response with the sample code for the keyboard but no errors pop up. I will look further into this.