The Arduino has built-in pullup resistors for inputs, but SoapBox Snap doesn't appear to use them. Is there a way to enable them when using the SoapBox Snap Arduino runtime?

asked 23 Jul '16, 14:55

Scott's gravatar image

Scott ♦♦
61138
accept rate: 13%


There's nothing built into the editor, but if you just wanted all your inputs to use pullups, you could do a one-line change to the IO.cpp file in the ArduinoFirmware folder before you download it to the Arduino.

Here's the file I'm talking about: ArduinoFirmwareIO.cpp

Specifically this function near the top:

void IO::configureIO() {
  for(int pin = MIN_PIN_NUMBER; pin <= MAX_PIN_NUMBER; pin++) {
    if(_deviceConfig->isOutput(pin) || _deviceConfig->isPwm(pin)) {
      pinMode(pin, OUTPUT);
    }  
    else {
      pinMode(pin, INPUT);
    }
  }
}

Just change the line:

pinMode(pin, INPUT);

to:

pinMode(pin, INPUT_PULLUP);

Then upload the sketch to the Arduino again.

link

answered 23 Jul '16, 14:58

Scott's gravatar image

Scott ♦♦
61138
accept rate: 13%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×4
×4

Asked: 23 Jul '16, 14:55

Seen: 5,429 times

Last updated: 23 Jul '16, 14:58

powered by OSQA