Archived
1
0
This repo is archived. You can view files and clone it, but cannot push or open issues or pull requests.
keybrd/tutorials/tutorial_6_active_high.md
2016-09-16 23:45:54 -06:00

4.6 KiB

Tutorial 6 - Active high

This tutorial pulls together several concepts needed to understand active state in the context of a keyboard. Skip to the end of this tutorial if you just want to copy an active-high keyboard.

Pull-up resistors

There are many sources that explain "pull-up resistors", so I won't repeat it here. Here is a good tutorial on Pull-up Resistors.

Active low

All the keyboards up to this point in the tutorial series have used active low with internal pull-up resistors.

"Active low" means that if a switch is pressed (active state), the read pin is low. When the switch is released (inactive state), the pull-up resistor pulls the read pin high.

The following table traces the strobe current from left to right (0 is ground, 1 is power). If the switch is closed, the strobe current passes through the switch and pulls the read pin low. If the switch is open, the pull-up resistor pulls the read pin high.

Strobe pin on Diode orientation Switch position Pull resistor Read pin state
0 cathode -:<- anode close 1 pull-up 0 active low
0 cathode -:<- anode open 1 pull-up 1 inactive high

Arduino boards have internal pull-up resistors, which saves on parts and labor compared to manually adding external pull resistors.

To make a keyboard active low:

  • Orient diodes with cathode (banded end) towards the write pins (row)
  • Define strobe on and strobe off in the sketch like this:
    const bool Scanner_uC::STROBE_ON = LOW;
    const bool Scanner_uC::STROBE_OFF = HIGH;

Active high

"Active high" means that if a switch is pressed (active), the read pin is high. When the switch is released (inactive), the pull-down resistor pulls the read pin low.

The following table traces the strobe current from left to right (0 is ground, 1 is power). If the switch is closed, the strobe current passes through the switch and pulls the read pin high. If the switch is open, the pull-down resistor pulls the read pin low.

Strobe pin on Diode orientation Switch position Pull resistor Read pin state
1 anode ->:- cathode close 0 pull-down 1 active high
1 anode ->:- cathode open 0 pull-down 0 inactive low

Arduino boards do not have internal pull-down resistors.
If you want to use active low, you will have to add external pull-down resistors to the read pins.

To make a keyboard active high:

  • Add an external 10k pull-down resistor to each read pin
  • Orient diodes with cathode (banded end) towards the read pins
  • Define strobe on and off in the sketch like this:
    const bool Scanner_uC::STROBE_ON = HIGH;
    const bool Scanner_uC::STROBE_OFF = LOW;

Making a breadboard keyboard active-high

This tutorial converts the basic breadboard keyboard from tutorial 1 to active high. By comparing the above tables, one can see what changes need to be made:

  • add external pull-down resistors to the read pins
  • flip the diodes so that the cathode (banded end) are towards the read pins
  • swap the STROBE_ON and STROBE_OFF values

The pull-down resistors plug into ground (red bus) and column read pins.

The keybrd_6_active_highsketch.ino is the tutorial 1 sketch with STROBE_ON and STROBE_OFF values swapped.

pull_down_resistors.JPG


Creative Commons License
keybrd tutorial by Wolfram Volpi is licensed under a Creative Commons Attribution 4.0 International License.
Permissions beyond the scope of this license may be available at https://github.com/wolfv6/keybrd/issues/new.