2016-07-18 02:03:03 +00:00
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.
2016-07-18 02:26:00 +00:00
Pull-up resistors
-----------------
2016-07-18 02:03:03 +00:00
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 ](https://learn.sparkfun.com/tutorials/pull-up-resistors/what-is-a-pull-up-resistor ).
2016-07-18 02:26:00 +00:00
Active low
----------
All the keyboards up to this point in the tutorial series have used active low with internal pull-up resistors.
2016-07-18 02:03:03 +00:00
"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.
2016-07-18 02:26:00 +00:00
< br >
2016-07-18 02:03:03 +00:00
|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 |
2016-07-18 02:26:00 +00:00
< br >
2016-07-18 02:03:03 +00:00
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)
2016-07-18 02:26:00 +00:00
* Define strobe on and strobe off in the sketch like this:
2016-07-18 02:03:03 +00:00
```
const bool Scanner_uC::STROBE_ON = LOW;
const bool Scanner_uC::STROBE_OFF = HIGH;
```
2016-07-18 02:26:00 +00:00
Active high
-----------
2016-07-18 02:03:03 +00:00
"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.
2016-07-18 02:26:00 +00:00
If the switch is open, the pull-down resistor pulls the read pin low.
< br >
2016-07-18 02:03:03 +00:00
|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 |
2016-07-18 02:26:00 +00:00
< br >
2016-07-18 02:03:03 +00:00
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;
```
2016-07-18 02:26:00 +00:00
Making a breadboard keyboard active-high
----------------------------------------
2016-07-18 02:03:03 +00:00
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
2016-09-17 05:45:12 +00:00
The pull-down resistors plug into ground (red bus) and column read pins.
2016-07-18 02:03:03 +00:00
2016-07-18 02:26:00 +00:00
The [keybrd_6_active_highsketch.ino ](keybrd_6_active_high/keybrd_6_active_high.ino ) is the tutorial 1 sketch with STROBE_ON and STROBE_OFF values swapped.
2016-07-18 02:03:03 +00:00
![pull_down_resistors.JPG ](keybrd_6_active_high/pull_down_resistors.JPG "Active-high diodes and pull-down resistors" )
2016-07-18 02:26:00 +00:00
< br >
2016-07-21 20:20:07 +00:00
< a rel = "license" href = "https://creativecommons.org/licenses/by/4.0/" > < img alt = "Creative Commons License" style = "border-width:0" src = "https://licensebuttons.net/l/by/4.0/88x31.png" / > < / a > < br / > < span xmlns:dct = "http://purl.org/dc/terms/" property = "dct:title" > keybrd tutorial< / span > by < a xmlns:cc = "https://creativecommons.org/ns" href = "https://github.com/wolfv6/keybrd" property = "cc:attributionName" rel = "cc:attributionURL" > Wolfram Volpi< / a > is licensed under a < a rel = "license" href = "https://creativecommons.org/licenses/by/4.0/" > Creative Commons Attribution 4.0 International License< / a > .< br / > Permissions beyond the scope of this license may be available at < a xmlns:cc = "https://creativecommons.org/ns" href = "https://github.com/wolfv6/keybrd/issues/new" rel = "cc:morePermissions" > https://github.com/wolfv6/keybrd/issues/new< / a > .