SISW-SPST

From Curuxa

Very simple push-button/bumper/switch.

This module is used as a very simple input method for sending signals to a microcontroller.

Contents

Electronic circuit

Schematic

Bill of materials:

  • 1x SPST push-button, bumper or switch. Normally open
  • 1x 10k 1/4W resistor
  • 1x 1k 1/4W resistor
  • 1x data connector
  • Some heat shrink tubing

How it works

It uses inverted logic: when the button is released, the microcontroller will receive a logic "1". When pressed, a logic "0" will be received. This way you can use SISW-SPST as a simple button to send signals to the microcontroller, as a contact sensor, or even as a reset button if you plug it to a MCLR pin on PIC microcontrollers.

The pin of the microcontroller where SISW-SPST is connected to has to be configured as a digital input.

When released, the switch is open. There is no current flow because digital inputs (on the microcontroller) are in "high impedance" mode. When there is no current flow, there is no voltage drop at the 10k resistor (R1), so the data pin is at the same voltage as Vcc, which means a logic "1".

When the button is pressed the switch is closed. There is a very small current flowing through the button and resistors. R1 is much bigger than R2, so there is a huge voltage drop at R1 but a small voltage drop at R2, meaning the data pin will be almost at ground level, so the microcontroller will read a logic "0".

SISW-SPST using data connector

Wiring

Wiring


Construction

SISW-SPST SISW-SPST SISW-SPST

SISW-SPST using homemade connector

Wiring

Wiring


Construction

SISW-SPST SISW-SPST SISW-SPST SISW-SPST

As you can see, only 2 pins are used. If your button/switch has only two pins, use those. If it has 3 pins, use only the two so it works as a normally-open switch (those two pins are short-circuit when the button is pressed, and unconnected when the button is released).

Printable version: Single, Quad

Test

C

The following code can be compiled using SDCC.

/*==================================================================
* Sample program for LTIND-A and SISW-SPST using an MBP18
*
* Plug SISW-SPST to RB3 (pin 9) and LTIND-A to RB4 (pin 10).
* The LED will light up while the button is pressed.
*
* http://curuxa.org
*=================================================================*/
 
#include <pic16f88.h>
 
typedef unsigned int config;
config at _CONFIG1 __CONFIG = _CP_OFF & _DEBUG_OFF & _WRT_PROTECT_OFF & _CPD_OFF & _LVP_OFF & _BODEN_OFF & _MCLR_OFF & _PWRTE_ON & _WDT_OFF & _INTRC_IO;
 
#define Button RB3
#define Pressed 0
#define Released
 
#define LED RB4
#define LedON 1
#define LedOFF 0
 
void main(){
	//set RB3 as a digital input and RB4 as a digital output
	TRISB3=1;
	TRISB4=0;
 
	while(1){
                if(Button==Pressed) LED=LedON;
                else LED=LedOFF;
	}
}