row_R1.process(); | row_R1.process(); | ||||
scanDelay.delay(); | scanDelay.delay(); | ||||
//debug.print_scans_per_second(); | |||||
//debug.print_microseconds_per_scan(); | |||||
//debug.printScansPerSecond(); | |||||
//debug.printMicrosecondsPerScan(); | |||||
} | } |
row_R1.process(); | row_R1.process(); | ||||
scanDelay.delay(); | scanDelay.delay(); | ||||
//debug.print_scans_per_second(); | |||||
//debug.print_microseconds_per_scan(); | |||||
//debug.printScansPerSecond(); | |||||
//debug.printMicrosecondsPerScan(); | |||||
} | } |
Intantiate DELAY_MICROSECONDS in your sketch: | Intantiate DELAY_MICROSECONDS in your sketch: | ||||
ScanDelay scanDelay(1000); | ScanDelay scanDelay(1000); | ||||
Add this to the sketch's loop() function: | Add this to the sketch's loop() function: | ||||
debug.print_microseconds_per_scan(); | |||||
debug.printMicrosecondsPerScan(); | |||||
Compile and load the sketch into the microcontroller; microseconds_per_scan is printed every second. | Compile and load the sketch into the microcontroller; microseconds_per_scan is printed every second. | ||||
Adjust the value of DELAY_MICROSECONDS and repeat until: | Adjust the value of DELAY_MICROSECONDS and repeat until: | ||||
debug.print_microseconds_per_scan() <= DEBOUNCE_TIME / SAMPLE_COUNT_MACRO | |||||
debug.printMicrosecondsPerScan() <= DEBOUNCE_TIME / SAMPLE_COUNT_MACRO | |||||
DEBOUNCE_TIME can be obtained from the switch's datasheet. Some switch bounce times are: | DEBOUNCE_TIME can be obtained from the switch's datasheet. Some switch bounce times are: | ||||
Cherry MX specifies 5msec bounce time http://www.cherrycorp.com/english/switches/key/mx.htm | Cherry MX specifies 5msec bounce time http://www.cherrycorp.com/english/switches/key/mx.htm |
row_R1.process(); | row_R1.process(); | ||||
scanDelay.delay(); | scanDelay.delay(); | ||||
//debug.print_scans_per_second(); | |||||
//debug.print_microseconds_per_scan(); | |||||
//debug.printScansPerSecond(); | |||||
//debug.printMicrosecondsPerScan(); | |||||
} | } |
row_R1.process(); | row_R1.process(); | ||||
scanDelay.delay(); | scanDelay.delay(); | ||||
//debug.print_scans_per_second(); | |||||
//debug.print_microseconds_per_scan(); | |||||
//debug.printScansPerSecond(); | |||||
//debug.printMicrosecondsPerScan(); | |||||
} | } |
current capacity of output pin If = 20 mA | current capacity of output pin If = 20 mA | ||||
continuous Forward Current of LED If = 30 mA | continuous Forward Current of LED If = 30 mA | ||||
minimum current limiting restiance is R = (Vs - Vf) / If = 55 Ohms | |||||
minimum current limiting resistance is R = (Vs - Vf) / If = 55 Ohms | |||||
``` | ``` | ||||
Add a safety margin for resistor tolerances (1%, 2%, 5%, 10%), and round up to a standard value. | Add a safety margin for resistor tolerances (1%, 2%, 5%, 10%), and round up to a standard value. | ||||
http://www.rfcafe.com/references/electrical/resistor-values.htm | http://www.rfcafe.com/references/electrical/resistor-values.htm |