CircuitGizmos

Electronic Products for Creative Minds

  • Home
  • Gizmo Store/Products
  • Documentation/Datasheets
  • Projects/Libraries
  • GizmoBlog
  • Services/Contact
    • Design
    • Contact Gizmo!
  • Your Gizmo Cart
    • Your Account
You are here: Home / GizmoBlog / MMBasic Language / Input and Output / Switch Input Pullup

Switch Input Pullup

Often there is a need to use a switch/button as an input to a MMBasic project. This is easy to implement as an input can be specified with an internal pullup resistor of about 100 kohm. This resistor is internal to the microcontroller and (when enabled) will be connect between the input pin and the 3.3V supply. This means that the switch can be connected between the ground and the input pin. When the switch/button is open the input will be high (pulled up by the internal resistor) and when closed the input will be zero.

To specify a pullup resistor you use SETPIN as follows:


SETPIN pin, DIN, PULLUP


When you use a switch/button you will also have to consider the issue of contact bounce. This is when the switch contacts mechanically touch and then bounce apart momentarily due to the momentum of the mechanical assembly. Because the MMBasic runs very fast a program could see this as a secession of quick button presses rather than a single press.

You could check for this in your program, for example by checking 100mS after the first contact closure to confirm that the contacts are indeed closed.

A simpler solution, but one involving a small amount of hardware, is to connect a 100nF capacitor across the switch contacts. This capacitor in association with the internal pullup resistor will average out any rapid contact bounce so that the program will see a smooth transition from on to off and vice versa.

A Ton of Documentation

Open all | Close all

Projects made by Gizmo, Friends, and Members

open all | close all

Recent GizmoBlog Musings

  • Altair 8800 using a ColorMax!
  • Re-energizing the ColorMax, Pt. 3

Visit us!

  • Facebook

Electronic Products for Creative Minds

CircuitGizmos is your source for electronic products that help you create your embedded projects. Here at CircuitGizmos.com you will find a friendly store filled with creative products and all of the documentation that you need to use these gizmos.

We create devices that we believe make electronics fun, but we also know that our products are used for professional designs. For decades we have designed products for commercial, military, and medical industries. Our gizmos here are great for engineers and hobbyists alike.

Copyright © 2008+ CircuitGizmos, L.L.C. All rights reserved

Image already added

Recently Viewed Products

Copyright © 2023 · Generate Pro Theme on Genesis Framework · WordPress · Log in