[ Log In ]

General description of push buttons and switches. Push buttons are momentary switches where the button must be held down to create a connection between its leads. Switches are generally devices that stay connected or stay not connected depending on the physical state of the switch (the lever is moved to the other side, or the switched is depressed and an internal mechanincal system has caused a change in the state).

General description of a push button switch and button switch schematic symbol. The push button is a momentary switch that will only cause its leads to connect when held in a pushed condition.

General explanation of push button and switch bounce. Removeing the push button or switch bounce is called debouncing the swith or push button. Debouncing can be addressed in two ways, software debouncing and hardware debouncing.

Connecting a push button switch to the microcontroller on a breadboard with a capacitor for hardware debouncing. The push button switch is connected to a general IO pin (in this case PORTB and Pin 1).

Programming for push button switch functionality on the Atmel AVR microcontroller on PORTB Pin 1 using the condition that uses the bit_is_clear(PIN?, ?) function. In this case, the push button has a capacitor to provide for hardware debouncing.

How to make a program for the Atmel AVR microcontroller using a push button to change the delay that an LED is blinking. The program uses the util/delay.h library and _delay_ms(delayAmount) function. Two delays are used: a 10 millisecond delay and a 100 millisecond delay.

How connect a push button to a microcontroller (make a circucit) and make a program for the Atmel AVR microcontroller using a push button to change the delay that an LED is blinking. The program uses the util/delay.h library and _delay_ms(delayAmount) function. Two delays are used: a 10 millisecond delay and a 100 millisecond delay.

Schematic on paper of one button with hardware debouncing and two LEDs (Light Emitting Diodes) connected to an AVR microcontroller. The push button switch is connected to pin 1 on PORT B and the LEDs are connected to pin 0 and pin 2 on the same port. These are green LEDs so a 330ohm resistor is used to limit the current through the LED.

Example of why debouncing for a push button is so important. The video shows schematic on paper of one button with hardware debouncing and two LEDs (Light Emitting Diodes) connected to an AVR microcontroller. The push button switch is connected to pin 1 on PORT B and the LEDs are connected to pin 0 and pin 2 on the same port. These are green LEDs so a 330ohm resistor is used to limit the current through the LED. The circuit is created on a breadboard and a program is written to toggle the two LEDs.

Breadboard circuit of one button with hardware debouncing and two LEDs (Light Emitting Diodes) connected to an AVR microcontroller. The push button switch is connected to pin 1 on PORT B and the LEDs are connected to pin 0 and pin 2 on the same port. These are green LEDs so a 330ohm resistor is used to limit the current through the LED.

Making a program for the Atmel AVR microcontroller to toggle two LEDs when a push button switch is pressed. When the push button is pressed and released, one LED is on, and when the push button is pressed and released again, the on LED is turned off and the other LED is turned on.

How to make a program for the push button switch for an Atmel AVR microcontroller so that the action is only activated when the push button is pressed then released. A condition using the function bit_is_clear is used to test for the push button press and then a variable is used to determine pressed state and released state. Within the condition, there is another condition to determine if the push button is in the released state before the push button is pressed. This means that the push button must have been released before the push button pressed action is invoked.

A test of the actual circuit with the Atmel AVR microcontroller programmed showing the push button with debouncing using a capacitor across the two leads of the push button switch. Two LEDs (Light Emitting Diodes) are toggled when the push button is pressed and released. Results show that without debouncing the LEDs sometimes toggle twice or three times with one button pressed and release.

Showing the bouncing (mechanical bounce) effect of a push button switch using an oscilloscope showing the effect of the voltage level when the push button is pressed.

Showing the bouncing (mechanical bounce) effect with an oscilloscope for a push button switch with hardware debouncing introduced using a capacitor showing the effect of the voltage level when the push button is pressed.

The rationalle of using one method over the other and the tradeoffs. In software debouncing, the trade off is the microcontroller requires a few more cycles which can slow the execution of the program slightly and the variables needed for software debouncing requires a bit of memory. The trade-off with hardware debouncing is that the extra hardware (capacitor or capacitor/resistor pair) will introduce a cost to the circuit where if the circuit will be used in a product that will have thousands, or many thousands of units made, a hardware solution may be too expensive.

A program is developed to investigate the elimination of button bounce (software push button debouncing). The circuit consists of two LEDs and a push button. The LEDs will toggle when the push button is pressed and then released. Two main variables are used in understanding the actual button press and button release. These are confidence levels of pressed and released. A threshold controls the button action.

An attempt is made to explain how the software debouncing works. A string of 0s and 1s are visually represented to show what may be going on when a button is pressed and a solution to overcome the portion of the 1s and 0s where there is uncertainty. A counter is used to increase a variable to represent the confidence level of the button press or release.

A push button is tested to determine if software debouncing is successful. Microcontroller used is an Atmel AVR Atmega32. Two LEDs are used to check if the button exhibited a bounce.

The control register of the timer/counter is TCCR1A and TCCR1B since the register is 16-bit, two 8-bit register designations are made. Each bit of the register is like a switch to turn on or off to control some aspect of the timer/counter.

TCCR1A has these switches: COM1A1, COM1A0, COM1B1, COM1B0, FOC1A, FOC1B, WGM11, WGM10.

To start the times, we will use the Clock Select CS12, CS11 and CS10. These control the prescaling of the clock source (i.e. how many actual clock ticks to ignore when counting). Setting only CS10 to 1 or high, this will set the timer/count to count with the clock source with no prescaling.

A voltage regulator takes a higher voltage and provides a set voltage that the regulator is designed to output. There are a few types of regulators: switching regulators, high dropout regulators and low dropout regulators. Regulators have an input and an output. The input is the raw voltage that you provide through battery, wall adapter, power supply, transformer (with rectification and smoothing with capacitors). The output is the voltage that the regulator is designed to provide.

Dropout is the amount of voltage the regulator needs to keep the rated output voltage.

Examples of common voltage regulators:
7805 - provides 5 volts and is a high dropout
Max603 - 5v output
Max604 - 3.3v output

The switch statement is a conditional statement. The switch statement is like a menu, and case is like the menu option. The switch will have a variable and each case statement will have a value that this variable may be matched.

The if else condition can be used as an alternative to the switch case conditional statement and vice versa.

The compressor is a machines that delivers constant pressurized air. The compressor is always making sure there is a minimum amount of pressure available. This is possible using a tank that holds the pressurized air, a pump that pushes air into the tank, a motor that actuates the pump, and a pressure switch that turns the motor on when the pressure in the tank falls below a set threshold.

A relay is a device that accepts a voltage to close or open (normally closed or normally open, or both) an internal switch in the relay. That is to say, a relay is a switch that is triggered by a voltage. The relay can control much higher voltages than what it takes to control it. The voltage that the relay will accept to control the switch is in this case 5v. Relays also exists that accept all kinds of voltage values. The triggering voltage is used to fire a coil that actuates the switch, so a bit more current may be necessary than what the microcontroller output pin can handle, so a transistor may be needed.

Relays are also available as latching and non-latching. That is to say, non-latching is when the voltage is applied the switch triggered until the voltage taken away. Latching is then the relay receives the voltage and when the voltage is released, the switch stays triggered. The switch will un-trigger when another pulse of voltage is sent.

The Relay requires a few other components to provide enough power to trip the relay coil (transistor) and a diode across the relay coil to protect the transistor from any back EMF that could be caused by the relay coil.

The relay will be controlled by a pin on the microcontroller. Since the microcontroller will not allow a draw of current that the relay coil will need, a transistor will be needed to switch on a higher current supply. The higher current supply is just the 5v that is powering the circuit. On of the pins of the transistor is connected to the pin of the microcontroller. This pin will have a resistor between the pin and the transistor (base). When the pin is high, the transistor will allow current to pass through the other two pins (collector and emitter).

The relay coil is connected to this part of the transistor so when the pin is high, the relay coil will fire. Since the coil can create back EMF, the coil will have a signal diode across the coil to keep any current from hitting the transistor.

A transistor is a device that can allow a high current to pass with a small current signal. A transistor can work two ways, either as an amplifier, or a switch. In this case, it will be used as a switch to apply current to a relay.

The transistor has three leads. The lead that serves as an input of a small current is called the base lead. When the base lead gets a small current, current can pass through the collector and emitter leads.

A resistor will most likely be needed at the base lead of a transistor if the transistor will be used as a switch. The formla below is a special formula that is used only if the supply voltage is the same as the voltage being applied to the base lead of the transistor

Resistance = LoadCurrent x LoadResistance x Hfe(transistor rated)

When there is a coil, or inductance in a circuit, there is a possibility of getting current in the reverse direction when the coil is switched off (current is released from that load). A diode is a device that can insure that a current in the reverse direction does not affect the surrounding components. The diode in this video clip is a 1N4001 signal diode rated at 1 amp. The circuit in this case is .2 amps.

The pin of the microcontroller is connected to a transistor that will switch on the current that will fire the coil of the relay so the relay can switch on. The pin of the microcontroller has a resistor to the base lead of the transistor.

A protection diode is connected to the two leads of the relay coil to protect the transistor from a current spike from the relay coil. The diode is a signal diode 1N4001.

This is a test of the pressure switch circuit with the relay connected to the microcontroller via the transistor.

The pin of the microcontroller is connected to a transistor that will switch on the current that will fire the coil of the relay so the relay can switch on. The pin of the microcontroller has a resistor to the base lead of the transistor.

A protection diode is connected to the two leads of the relay coil to protect the transistor from a current spike from the relay coil. The diode is a signal diode 1N4001.

The push button switch is connected to the first pin of the microcontroller (PORTB Pin 0) and the other end of the button is connected to ground since the pin will be in a high state.

This is the result of the one way communication of one microcontroller transmitting through its TX pin and another microcontroller receiving through the RX pin. A push button switch is connected to the transmitting microcontroller to initiate the transmit. Both microcontrollers have an LED to show the successful push button switch press and the show a successful transmission on the other microcontroller.

Darlington transistors are a couple of transistors connected together. The benefit of using a darlington transistor over a standard transistor is the higher beta value. The higher beta value allows a very small amount of current to control the transistors. In the case of a darlington transistor that controls a 2 amp load would only require a 2mA (milliamp) load from the microcontroller.

It is recommended only to switch medium current loads, like up to 3 amps as the voltage drop is high with darlington transistors. If higher current loads are needed to be switched, use a mosfet rather than a darlington transistor.

An attribute can be toggled or affected using the begin overlap event.

This example: toggle or turn a light on when in proximity to the light.


In the placement browser, select volumes. Scroll to the trigger volume. Use the move and scale tools to position the volume where you would expect a pawn to trigger.