gangstertim
Member
Hi all,
I'm new to this—bear with me! I've spent the last hour puzzling over two very small programs which each work on their own, but don't work when combined.
Program 1 is a proof-of-concept that my pushbutton works. It behaves as expected: I push the button, the light turns off:
Program 2 is a proof-of-concept that the keyboard works. It works as expected: every 6 seconds, it prints "hello":
But when I combine the two, and put my keyboard print line in Program 1, the LED portion still works but it never prints:
Clearly, I'm missing something. What gives?
I'm new to this—bear with me! I've spent the last hour puzzling over two very small programs which each work on their own, but don't work when combined.
Program 1 is a proof-of-concept that my pushbutton works. It behaves as expected: I push the button, the light turns off:
Code:
void setup() {
pinMode(13, OUTPUT);
}
void loop() {
if (digitalRead(4) == LOW) { //Pushbutton on pin 4
analogWrite(13, 200);
} else {
analogWrite(13, 0);
}
delay(5); //Slow things down a bit
}
Program 2 is a proof-of-concept that the keyboard works. It works as expected: every 6 seconds, it prints "hello":
Code:
void setup() {}
void loop() {
Keyboard.print("hello");
delay(6000);
}
But when I combine the two, and put my keyboard print line in Program 1, the LED portion still works but it never prints:
Code:
void setup() {
pinMode(13, OUTPUT);
}
void loop() {
if (digitalRead(4) == LOW) { //Pushbutton on pin 4
analogWrite(13, 200);
} else {
analogWrite(13, 0);
Keyboard.print("hello");
}
delay(5); //Slow things down a bit
}
Clearly, I'm missing something. What gives?