Skip to main content
added 188 characters in body
Source Link
hur
  • 103
  • 4

Here's sample code to demonstrate my problem:

#include <DigiKeyboard.h>

void setup() {
  // put your setup code here, to run once:
  delay(5000);
  DigiKeyboard.print("TESTING TESTING");
  pinMode(1,OUTPUT);
  digitalWrite(1,HIGH);
}

void loop() {
  // put your main code here, to run repeatedly:
}

My problem is that I can't get Digikeyboard.print() or other Digikeyboard commands (e.g. sendKeyStroke()) to do anything while they are located inside the setup function. The led command after the print command executes properly.

The print command will work if I place it inside the loop function. However, I want to only execute this code once.

Any assistance would be appreciated, and I would be happy to provide more information if necessary.

EDIT: I worked around this by using a if-expression inside the loop function to only run the code once. However, I am still interested in learning why my original code doesn't work.

Here's sample code to demonstrate my problem:

#include <DigiKeyboard.h>

void setup() {
  // put your setup code here, to run once:
  delay(5000);
  DigiKeyboard.print("TESTING TESTING");
  pinMode(1,OUTPUT);
  digitalWrite(1,HIGH);
}

void loop() {
  // put your main code here, to run repeatedly:
}

My problem is that I can't get Digikeyboard.print() or other Digikeyboard commands (e.g. sendKeyStroke()) to do anything while they are located inside the setup function. The led command after the print command executes properly.

The print command will work if I place it inside the loop function. However, I want to only execute this code once.

Any assistance would be appreciated, and I would be happy to provide more information if necessary.

Here's sample code to demonstrate my problem:

#include <DigiKeyboard.h>

void setup() {
  // put your setup code here, to run once:
  delay(5000);
  DigiKeyboard.print("TESTING TESTING");
  pinMode(1,OUTPUT);
  digitalWrite(1,HIGH);
}

void loop() {
  // put your main code here, to run repeatedly:
}

My problem is that I can't get Digikeyboard.print() or other Digikeyboard commands (e.g. sendKeyStroke()) to do anything while they are located inside the setup function. The led command after the print command executes properly.

The print command will work if I place it inside the loop function. However, I want to only execute this code once.

Any assistance would be appreciated, and I would be happy to provide more information if necessary.

EDIT: I worked around this by using a if-expression inside the loop function to only run the code once. However, I am still interested in learning why my original code doesn't work.

Source Link
hur
  • 103
  • 4

Digispark / Digikeyboard code doesn't execute inside setup{}

Here's sample code to demonstrate my problem:

#include <DigiKeyboard.h>

void setup() {
  // put your setup code here, to run once:
  delay(5000);
  DigiKeyboard.print("TESTING TESTING");
  pinMode(1,OUTPUT);
  digitalWrite(1,HIGH);
}

void loop() {
  // put your main code here, to run repeatedly:
}

My problem is that I can't get Digikeyboard.print() or other Digikeyboard commands (e.g. sendKeyStroke()) to do anything while they are located inside the setup function. The led command after the print command executes properly.

The print command will work if I place it inside the loop function. However, I want to only execute this code once.

Any assistance would be appreciated, and I would be happy to provide more information if necessary.