Guidance on how to emulate keyboard on Dell startup

Hello everyone,

I am a newbie to arduino board and programming but I enjoyed working on the centepede project shown here:

I used the Pro Micro board to automate keystrokes on chromebooks to autoamatically provision them.

After a while, I found ways to change the keystrokes so I can log into an account and check for updates; then powerwash after 15 minutes.

Now I want to try have the arduino board invoke the boot order key on startup on a dell desktop and then choose a different option. However, when I try to plug it in, nothing happens. I was wondering if I am missing something or should change something.

Here is the test code I have. I know its redundant but I did it purposely to see if something would happen when the computer is starting up on POST/BIOS boot. Also, there are certain function to which I am not fully sure what they refer to such as, "buttonPin", "RXLED", "cycles", "static uint8_t __clock_prescaler":

Any advice or suggestions would be greatly appriciated

#include <Keyboard.h>

#define slowMode 1 // Set to 1 if Centipede appears to be moving too quickly at any screen. This will slow down the entire process


// Special characters definition
#define KEY_LEFT_CTRL  0x80
#define KEY_LEFT_SHIFT 0x81
#define KEY_LEFT_ALT   0x82
#define KEY_RIGHT_CTRL 0x84
#define KEY_RIGHT_SHIFT    0x85
#define KEY_RIGHT_ALT  0x86
#define KEY_UP_ARROW   0xDA
#define KEY_DOWN_ARROW 0xD9
#define KEY_LEFT_ARROW 0xD8
#define KEY_RIGHT_ARROW    0xD7
#define KEY_BACKSPACE  0xB2
#define KEY_TAB        0xB3
#define KEY_ENTER 0xB0
#define KEY_ESC        0xB1
#define KEY_CAPS_LOCK  0xC1
#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


int buttonPin = 2;  // Set a button to any pin
int RXLED = 17;
static uint8_t __clock_prescaler = (CLKPR & (_BV(CLKPS0) | _BV(CLKPS1) | _BV(CLKPS2) | _BV(CLKPS3)));


void wait(int cycles = 1);

void bypassJumper() {
  wait(2);
  Keyboard.write(KEY_UP_ARROW);
  Keyboard.write(KEY_UP_ARROW);
  Keyboard.write(KEY_UP_ARROW);
  Keyboard.write(KEY_UP_ARROW);
  Keyboard.write(KEY_UP_ARROW);
  wait(8);
}

void bootScreen() {
  wait(2);
  Keyboard.write(KEY_UP_ARROW);
  Keyboard.write(KEY_UP_ARROW);
  Keyboard.write(KEY_UP_ARROW);
  Keyboard.write(KEY_UP_ARROW);
  Keyboard.write(KEY_UP_ARROW);
  wait(8);
}

void biosFolder() {
  wait(2);
  Keyboard.write(KEY_UP_ARROW);
  Keyboard.write(KEY_UP_ARROW);
  Keyboard.write(KEY_UP_ARROW);
  Keyboard.write(KEY_UP_ARROW);
  Keyboard.write(KEY_UP_ARROW);
  wait(8);
}

void updateBios() {
  wait(2);
  Keyboard.write(KEY_F12);
  Keyboard.write(KEY_F12);
  Keyboard.write(KEY_F12);
  Keyboard.write(KEY_F12);
  Keyboard.write(KEY_F12);
  wait(8);
}


void bootLoop() {
  //      digitalWrite(RXLED, LOW);   // set the LED on
  TXLED0; //TX LED is not tied to a normally controlled pin
  delay(200);              // wait for a second
  TXLED1;
  delay(200);
  TXLED0; //TX LED is not tied to a normally controlled pin
  delay(200);              // wait for a second
  TXLED1;
  delay(800);
}

void showSuccess() {
  digitalWrite(RXLED, HIGH);  // set the LED off
  while (true) {
    bootLoop();
  }
}

void repeatKey(byte key, int num) {
  for (int i = 0; i < num; i++) {
    Keyboard.write(key);
    wait(1);
  }
}

void blink() {
  digitalWrite(RXLED, LOW);
  //  TXLED1;
  delay(250);
  digitalWrite(RXLED, HIGH);
  //  TXLED0;
  delay(250);
}

void wait(int cycles) {
  for (int i = 0; i < cycles; i++) {
    blink();
    if (slowMode) {
      delay(250);
    }
  }
}

void setPrescaler() {
  // Disable interrupts.
  uint8_t oldSREG = SREG;
  cli();

  // Enable change.
  CLKPR = _BV(CLKPCE); // write the CLKPCE bit to one and all the other to zero

  // Change clock division.
  CLKPR = 0x0; // write the CLKPS0..3 bits while writing the CLKPE bit to zero

  // Copy for fast access.
  __clock_prescaler = 0x0;

  // Recopy interrupt register.
  SREG = oldSREG;
}

void setup()
{
  setPrescaler(); // Set prescaler to highest clock speed
  Keyboard.begin(); // Start they keyboard emulator
  pinMode(buttonPin, INPUT);  // Set up the debugging pin. If you want to debug the code, use a length of wire to connect pins 2 and GND on the board
  digitalWrite(buttonPin, HIGH);

  pinMode(RXLED, OUTPUT); // Configure the on-board LED
  digitalWrite(RXLED, LOW);
  TXLED1;
  if (digitalRead(buttonPin) == 0) {
    showSuccess();
  }
  wait(5); // Wait for all services to finish loading
}

void loop() {
  if (digitalRead(buttonPin) == 1 ) { // Check for debugging. If not debugging, run the program       
    bypassJumper(); // Bypass the jumper error
    bootScreen(); // Choose USB for boot
    biosFolder(); // select the right folder bios flash
    updateBios(); // accept Bios
    }
    showSuccess();   
  }

Hi,
You want to select during boot cycle how the boot is conducted.
During boot up, how will your USB control system be recognized?

What does your trial code do?

Thanks.. Tom.. :slight_smile: