Driver error

I trying to use my MKR Zero as a keyboard(specifically adding F1-F12 and voliume buttone. When i try to press any buttons, nothing happens. Not even resseting the board works. After going into my computer settings and checking the device properties ive determined tht the driver im using isnt responding. Is there something wrong with the board? or is there something else wrong. I got the board off arduino's amazon page.

images showing the issue are attached, Here's the code im using:

//Board used: ARDUINO MKR ZERO
#include <Keyboard.h>
#define KEY_F1			  	0xC2
#define KEY_F2				  0xC3
#define KEY_F3			  	0xC4
#define KEY_F4		  		0xC5
#define KEY_F5	  			0xC6
#define KEY_F6  				0xC7
#define KEY_F7				  0xC8
#define KEY_F8			  	0xC9
#define KEY_F9		  		0xCA
#define KEY_F10	  			0xCB //Keys being programmed
#define KEY_F11 	  		0xCC
#define KEY_F12		  	  0xCD
#define KEY_MUTE		  	0x7F
#define KEY_VOLUMEUP  	0x80
#define KEY_VOLUMEDOWN	0x81
int F1 = 1;
int F2 = 2;
int F3 = 3;
int F4 = 4;
int F5 = 5;
int F6 = 6;
int F7 = 7;
int F8 = 8;
int F9 = 9;
int F10 = 10;
int F11 = 11;
int F12 = 12;
int VolMute = 16;
int VolUp = 17;
int VolDown = 18;
void setup() {
Keyboard.begin();
  pinMode(F1, INPUT);
  pinMode(F2, INPUT);
  pinMode(F3, INPUT);
  pinMode(F4, INPUT);
  pinMode(F5, INPUT);
  pinMode(F6, INPUT);
  pinMode(F7, INPUT);
  pinMode(F8, INPUT);
  pinMode(F9, INPUT);
  pinMode(F10, INPUT);
  pinMode(F11, INPUT);
  pinMode(F12, INPUT);
  pinMode(VolMute, INPUT);
  pinMode(VolUp, INPUT);
  pinMode(VolDown, INPUT);
  pinMode(LED_BUILTIN, OUTPUT); //Helps me see that the board is working
  digitalWrite(LED_BUILTIN, HIGH);
}

void loop() {
  if (F1 == HIGH){
    Keyboard.press(KEY_F1);
    delay(30);
    Keyboard.release(KEY_F1);
  }
  else if (F2 == HIGH){
    Keyboard.press(KEY_F2);
    delay(30);
    Keyboard.release(KEY_F2);
  }
  else if (F3 == HIGH){
    Keyboard.press(KEY_F3);
    delay(30);
    Keyboard.release(KEY_F3);
  }
  else if (F4 == HIGH){
    Keyboard.press(KEY_F4);
    delay(30);
    Keyboard.release(KEY_F4);
  }
  else if (F5 == HIGH){
    Keyboard.press(KEY_F5);
    delay(30);
    Keyboard.release(KEY_F5);
  }
  else if (F6 == HIGH){
    Keyboard.press(KEY_F6);
    delay(30);
    Keyboard.release(KEY_F6);
  }
  else if (F7 == HIGH){
    Keyboard.press(KEY_F7);
    delay(30);
    Keyboard.release(KEY_F7);
  }
  else if (F8 == HIGH){
    Keyboard.press(KEY_F8);
    delay(30);
    Keyboard.release(KEY_F8);
  }
  else if (F9 == HIGH){
    Keyboard.press(KEY_F9);
    delay(30);
    Keyboard.release(KEY_F9);
  }
  else if (F10 == HIGH){
    Keyboard.press(KEY_F10);
    delay(30);
    Keyboard.release(KEY_F10);
  }
  else if (F11 == HIGH){
    Keyboard.press(KEY_F11);
    delay(30);
    Keyboard.release(KEY_F11);
  }
  else if (F12 == HIGH){
    Keyboard.press(KEY_F12);
    delay(30);
    Keyboard.release(KEY_F12);
  }
  else if (VolUp == HIGH){
    Keyboard.press(KEY_VOLUMEUP);
    delay(30);
    Keyboard.release(KEY_VOLUMEUP);
  }
  else if (VolDown == HIGH){
    Keyboard.press(KEY_VOLUMEDOWN);
    delay(30);
    Keyboard.release(KEY_VOLUMEDOWN);
  }
  else if (VolMute == HIGH){
    Keyboard.press(KEY_MUTE);
    delay(30);
    Keyboard.release(KEY_MUTE);
  }
}

bluetooth and other devices mkrzero.PNG

bluetooth and other devices mkrzero.PNG

Allspice101:

  if (F1 == HIGH){

I recommend you to study these reference materials to learn how to use the Arduino digitalRead() function:

So i saw that, a few hours after i posted this, still doesnt work, the driver still isnt working.
updated code:

#include <Keyboard.h>
#define KEY_F1			  	0xC2
#define KEY_F2				  0xC3
#define KEY_F3			  	0xC4
#define KEY_F4		  		0xC5
#define KEY_F5	  			0xC6
#define KEY_F6  				0xC7
#define KEY_F7				  0xC8
#define KEY_F8			  	0xC9
#define KEY_F9		  		0xCA
#define KEY_F10	  			0xCB
#define KEY_F11 	  		0xCC
#define KEY_F12		  	  0xCD
#define KEY_MUTE		  	0x7F
#define KEY_VOLUMEUP  	0x80
#define KEY_VOLUMEDOWN	0x81
int F1 = 1;
int F2 = 2;
int F3 = 3;
int F4 = 4;
int F5 = 5;
int F6 = 6;
int F7 = 7;
int F8 = 8;
int F9 = 9;
int F10 = 10;
int F11 = 11;
int F12 = 12;
int VolMute = 16;
int VolUp = 17;
int VolDown = 18;
void setup() {
Keyboard.begin();
  pinMode(F1, INPUT);
  pinMode(F2, INPUT);
  pinMode(F3, INPUT);
  pinMode(F4, INPUT);
  pinMode(F5, INPUT);
  pinMode(F6, INPUT);
  pinMode(F7, INPUT);
  pinMode(F8, INPUT);
  pinMode(F9, INPUT);
  pinMode(F10, INPUT);
  pinMode(F11, INPUT);
  pinMode(F12, INPUT);
  pinMode(VolMute, INPUT);
  pinMode(VolUp, INPUT);
  pinMode(VolDown, INPUT);
  pinMode(LED_BUILTIN, OUTPUT);
  digitalWrite(LED_BUILTIN, HIGH);
}

void loop() {
  if (digitalRead(F1) == HIGH){
    Keyboard.press(KEY_F1);
    delay(30);
    Keyboard.release(KEY_F1);
  }
  else if (digitalRead(F2) == HIGH){
    Keyboard.press(KEY_F2);
    delay(30);
    Keyboard.release(KEY_F2);
  }
  else if (digitalRead(F3) == HIGH){
    Keyboard.press(KEY_F3);
    delay(30);
    Keyboard.release(KEY_F3);
  }
  else if (digitalRead(F4) == HIGH){
    Keyboard.press(KEY_F4);
    delay(30);
    Keyboard.release(KEY_F4);
  }
  else if (digitalRead(F5) == HIGH){
    Keyboard.press(KEY_F5);
    delay(30);
    Keyboard.release(KEY_F5);
  }
  else if (digitalRead(F6) == HIGH){
    Keyboard.press(KEY_F6);
    delay(30);
    Keyboard.release(KEY_F6);
  }
  else if (digitalRead(F7) == HIGH){
    Keyboard.press(KEY_F7);
    delay(30);
    Keyboard.release(KEY_F7);
  }
  else if (digitalRead(F8) == HIGH){
    Keyboard.press(KEY_F8);
    delay(30);
    Keyboard.release(KEY_F8);
  }
  else if (digitalRead(F9) == HIGH){
    Keyboard.press(KEY_F9);
    delay(30);
    Keyboard.release(KEY_F9);
  }
  else if (digitalRead(F10) == HIGH){
    Keyboard.press(KEY_F10);
    delay(30);
    Keyboard.release(KEY_F10);
  }
  else if (digitalRead(F11) == HIGH){
    Keyboard.press(KEY_F11);
    delay(30);
    Keyboard.release(KEY_F11);
  }
  else if (digitalRead(F12) == HIGH){
    Keyboard.press(KEY_F12);
    delay(30);
    Keyboard.release(KEY_F12);
  }
  else if (digitalRead(VolUp) == HIGH){
    Keyboard.press(KEY_VOLUMEUP);
    delay(30);
    Keyboard.release(KEY_VOLUMEUP);
  }
  else if ((VolDown) == HIGH){
    Keyboard.press(KEY_VOLUMEDOWN);
    delay(30);
    Keyboard.release(KEY_VOLUMEDOWN);
  }
  else if (digitalRead(VolMute) == HIGH){
    Keyboard.press(KEY_MUTE);
    delay(30);
    Keyboard.release(KEY_MUTE);
  }
}

You missed one:

Allspice101:

  else if ((VolDown) == HIGH){

Do you have pull-down resistors connected to all these input pins?

ill need to rewire this thing, my main issue is that the driver for my mkr zero isnt working. if you need to see, i have images uploaded to the original post

That driver problem could be caused by the keyboard emulation spamming keypresses 33 times a second.

Does it still occur if you upload the File > New sketch?

only when keyboard.h is declared

would adding a 300ms delay at the end fix things?

Allspice101:
only when keyboard.h is declared

Do you mean that you get the same driver problem if you upload this sketch?

#include <Keyboard.h>
void setup() {}
void loop() {}

yes

im going to try it with the mouse library. see if it’s an issue with the usb libraries still getting the driver error

Current iteration:

#include <Keyboard.h>
/* My laptop's F1-F12 keys require me to press
and hold the fn key in order to use, so im
creating this so that i dont need to do that.*/
#define KEY_F1			  	0xC2
#define KEY_F2				  0xC3
#define KEY_F3			  	0xC4
#define KEY_F4		  		0xC5 
#define KEY_F5	  			0xC6
#define KEY_F6  				0xC7
#define KEY_F7				  0xC8
#define KEY_F8			  	0xC9
#define KEY_F9		  		0xCA
#define KEY_F10	  			0xCB
#define KEY_F11 	  		0xCC
#define KEY_F12		  	  0xCD
// just so that i can easilly change the voliume
#define KEY_MUTE		  	0x7F
#define KEY_VOLUMEUP  	0x80
#define KEY_VOLUMEDOWN	0x81
// Give the pin names
int F1 = 1;
int F2 = 2;
int F3 = 3;
int F4 = 4;
int F5 = 5;
int F6 = 6;
int F7 = 7;
int F8 = 8;
int F9 = 9;
int F10 = 10;
int F11 = 11;
int F12 = 12;
int VolMute = 16;
int VolUp = 17;
int VolDown = 18;
void setup() {
  Keyboard.begin();
  //pinmodes,
  pinMode(F1, INPUT_PULLUP);
  pinMode(F2, INPUT_PULLUP);
  pinMode(F3, INPUT_PULLUP);
  pinMode(F4, INPUT_PULLUP);
  pinMode(F5, INPUT_PULLUP);
  pinMode(F6, INPUT_PULLUP);
  pinMode(F7, INPUT_PULLUP);
  pinMode(F8, INPUT_PULLUP);
  pinMode(F9, INPUT_PULLUP);
  pinMode(F10, INPUT_PULLUP);
  pinMode(F11, INPUT_PULLUP);
  pinMode(F12, INPUT_PULLUP);
  pinMode(VolMute, INPUT_PULLUP);
  pinMode(VolUp, INPUT_PULLUP);
  pinMode(VolDown, INPUT_PULLUP);
  pinMode(LED_BUILTIN, OUTPUT);
  digitalWrite(LED_BUILTIN, HIGH);

void loop() {
  if (digitalRead(F1) == HIGH){
    Keyboard.press(KEY_F1);
    delay(30);
    Keyboard.release(KEY_F1);
  }
  else if (digitalRead(F2) == HIGH){
    Keyboard.press(KEY_F2);
    delay(30);
    Keyboard.release(KEY_F2);
  }
  else if (digitalRead(F3) == HIGH){
    Keyboard.press(KEY_F3);
    delay(30);
    Keyboard.release(KEY_F3);
  }
  else if (digitalRead(F4) == HIGH){
    Keyboard.press(KEY_F4);
    delay(30);
    Keyboard.release(KEY_F4);
  }
  else if (digitalRead(F5) == HIGH){
    Keyboard.press(KEY_F5);
    delay(30);
    Keyboard.release(KEY_F5);
  }
  else if (digitalRead(F6) == HIGH){
    Keyboard.press(KEY_F6);
    delay(30);
    Keyboard.release(KEY_F6);
  }
  else if (digitalRead(F7) == HIGH){
    Keyboard.press(KEY_F7);
    delay(30);
    Keyboard.release(KEY_F7);
  }
  else if (digitalRead(F8) == HIGH){
    Keyboard.press(KEY_F8);
    delay(30);
    Keyboard.release(KEY_F8);
  }
  else if (digitalRead(F9) == HIGH){
    Keyboard.press(KEY_F9);
    delay(30);
    Keyboard.release(KEY_F9);
  }
  else if (digitalRead(F10) == HIGH){
    Keyboard.press(KEY_F10);
    delay(30);
    Keyboard.release(KEY_F10);
  }
  else if (digitalRead(F11) == HIGH){
    Keyboard.press(KEY_F11);
    delay(30);
    Keyboard.release(KEY_F11);
  }
  else if (digitalRead(F12) == HIGH){
    Keyboard.press(KEY_F12);
    delay(30);
    Keyboard.release(KEY_F12);
  }
  else if (digitalRead(VolUp) == HIGH){
    Keyboard.press(KEY_VOLUMEUP);
    delay(30);
    Keyboard.release(KEY_VOLUMEUP);
  }
  else if (digitalRead(VolDown) == HIGH){
    Keyboard.press(KEY_VOLUMEDOWN);
    delay(30);
    Keyboard.release(KEY_VOLUMEDOWN);
  }
  else if (digitalRead(VolMute) == HIGH){
    Keyboard.press(KEY_MUTE);
    delay(30);
    Keyboard.release(KEY_MUTE);
  }
}

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.