ConformalConic ConformalConic - 4 months ago
253 0

Error --->
exit status 1
'Keyboard' not found. Does your sketch include the line '#include '?"

C#

Arduino Uno R3 Code

Embed
// libraries
#include <Keyboard.h>

// definitions
#define DECREMENT 2
#define INCREMENT 4
#define LOG 3
#define pause 200

//variables
int incPrevState = LOW;
int decPrevState = LOW;
int logPrevState = LOW;
int logging = false;

void setup() {
  pinMode(INCREMENT,INPUT);
  pinMode(DECREMENT,INPUT);
  pinMode(LOG,INPUT);
  Serial.begin(9600);
  Keyboard.begin();
}

void loop(){
  
 int incState = digitalRead(INCREMENT);
 int decState = digitalRead(DECREMENT);
 int logState = digitalRead(LOG);
  
  if((incState != incPrevState) && (incState == HIGH)){
    //Serial.println("INCREMENT");
    //Keyboard.press(KEY_LEFT_CTRL);
    Keyboard.press('i');
    delay(pause);
    Keyboard.releaseAll();
  }

  if((decState != decPrevState) && (decState == HIGH)){
    Serial.println("DECREMENT");   //for debugging
    //Keyboard.press(KEY_LEFT_CTRL);
    Keyboard.press('d');
    delay(pause);
    Keyboard.releaseAll();
  }

  if((logState != logPrevState) && (logState == HIGH)){
    if(logging == false){
    //Serial.println("LOG");   //for debugging
    //Keyboard.press(KEY_LEFT_CTRL);
    Keyboard.press('s');
    logging = true;
    delay(pause + 400);
    Keyboard.releaseAll();
    }
 else{
      if(logging == true){
      //Serial.println("STOP LOGGING");   // for debugging
      //Keyboard.press(KEY_LEFT_CTRL);
      Keyboard.press('e');
      logging = false;
      delay(pause + 400);
      Keyboard.releaseAll();
     }
    }
}
 incPrevState = incState;
 decPrevState = decState;
 logPrevState = logState;
  }
Comments