Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds missing pinMode #8312

Merged
merged 3 commits into from
Jun 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions libraries/USB/examples/CompositeDevice/CompositeDevice.ino
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ void setup() {
HWSerial.begin(115200);
HWSerial.setDebugOutput(true);

pinMode(buttonPin, INPUT_PULLUP);

USB.onEvent(usbEventCallback);
USBSerial.onEvent(usbEventCallback);
MSC_Update.onEvent(usbEventCallback);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,18 @@ USBHIDKeyboard Keyboard;
// change this to match your platform:
int platform = OSX;

const int buttonPin = 0; // input pin for pushbutton

void setup() {
// make pin 0 an input and turn on the pull-up resistor so it goes high unless
// connected to ground:
pinMode(0, INPUT_PULLUP);
pinMode(buttonPin, INPUT_PULLUP);
Keyboard.begin();
USB.begin();
}

void loop() {
while (digitalRead(0) == HIGH) {
while (digitalRead(buttonPin) == HIGH) {
// do nothing until pin 2 goes low
delay(500);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ void loop(){}
#include "USBHIDKeyboard.h"
USBHIDKeyboard Keyboard;

const int buttonPin = 0; // input pin for pushbutton

// use this option for OSX.
// Comment it out if using Windows or Linux:
char ctrlKey = KEY_LEFT_GUI;
Expand All @@ -45,14 +47,14 @@ char ctrlKey = KEY_LEFT_GUI;
void setup() {
// make pin 0 an input and turn on the pull-up resistor so it goes high unless
// connected to ground:
pinMode(0, INPUT_PULLUP);
pinMode(buttonPin, INPUT_PULLUP);
// initialize control over the keyboard:
Keyboard.begin();
USB.begin();
}

void loop() {
while (digitalRead(0) == HIGH) {
while (digitalRead(buttonPin) == HIGH) {
// do nothing until pin 0 goes low
delay(500);
}
Expand Down