Deprecated: Function create_function() is deprecated in /var/www/blog/inc/libs/clearbricks/common/lib.l10n.php on line 640

Deprecated: Function create_function() is deprecated in /var/www/blog/inc/libs/clearbricks/common/lib.http.php on line 249
Here is why I hate Arduino - Grumpycoder
Flux RSS

Here is why I hate Arduino

I've said in the past I hate Arduino. Here is a prime example of why.

Read that page, then allow me to explain exactly what's wrong here.

What's utterly wrong with this page is the "multi-keypress" feature. They don't explain how it works, they don't talk about its outstanding issues, and more importantly, they don't bother linking to the various discussions talking about the issues. And worst of all, it's just wrong. But to understand why, one needs to understand how a keypad works first.

A keypad is a matrix of switches. For a 4x4 keypad, you don't want to draw 16 wires from your MCU to each individual switch. Instead, you have the switches organized in columns and lines. Consider the following keypad:

| 1 | 2 | 3 | A |
| 4 | 5 | 6 | B |
| 7 | 8 | 9 | C |
| * | 0 | # | D |

Each switch has two connectors - let's call them left and right for this exercise. In the keypad above, the left connector for the buttons 1, 2, 3 and A are tied to each other. The right connector for the buttons 1, 4, 7 and * are tied to each other. I will now link to the picture from that guy's article, which illustrate this perfectly:

What that gives us is that there is a unique combination of two wires that ultimately will be connected to each other for each switch that is pressed. From that schematics, if you press 1, wires RC.3 and RC.7 will be connected together. If you press 0, wires RC.0 and RC.6 will be connected together.

So how do you read keypads from a microcontroller ? The answer is simple: you connect the 4 "column" wires to 4 output pins of your microcontroller, and the 4 "lines" wires to 4 input pins. You create a quick software loop that will turn 3 of the columns into pull downs, and one into a 3.3V or 5V output. From here, you read the status of the 4 lines, and you can determine if a switch is activated on that column. If you activate the first column, and you read that the second line has voltage on it, it means that the button 4 is pressed. Then you quickly switch to the next column, and so on. When you've done all columns, you start over. This is a scanning process that will read each 4 switch of one column at once, then go the next column, etc.

You may think that this properly supports simultaneous key presses: if you activate the first column, and read voltage from the first and third lines, you could deduce that keys 1 and 7 are pressed. But that could be wrong. It could be that keys 1, 3 and 9 are pressed. If you look at the circuit carefully, pressing simultaneously 1, 3 and 9 will create a full circuit. Powering on the first column will make the current go down to button 1. From here, it'll go the left to reach wire RC.3, but will also go to the right until it reaches the button 7. Then it will go up towards RC.5, but that's fine and won't fry the MCU, because it's set as pull down, but will also go down towards button 9, and then left until it reaches wire RC.1. So while activating the first column, you'll read the third line. Meaning that your MCU will ultimately think that buttons 1, 3, 7 and 9 are pressed, while only 1, 3 and 9 actually are, effectively creating a phantom activation of 7.

And this is basic knowledge. It really is. That's just basic switches tied together creating a closed circuit. You see that while being in 5th grade. Put several switches together, add a small lamp, press all switches together, and voilĂ , the circuit is closed, and the lamp lights up! This is problem known since decades, as it affects pinball machines that will do similar tricks to read all of the table switches without using an insane amount of wires. It has been solved in pinball machines using a well known technique that involves placing a diode alongside each switch, so that the current can't go "right". But that's something that you can't hack into a keypad easily. Some keypad will have diodes, some won't. Yet, no mention of it on the dedicated keypad page. And one guy quickly mentions it on their forum, but only got crickets 3 years ago.

I consider that to be highly subpar quality. I don't want to deal with a library that exposes countless APIs without at least talking about their pros and cons, in a manner that proves that they know what they're talking about. And according to the page, this is written by the main wire library maintainer. In fact, if anything, it proves they don't know what they're talking about, which makes me want to print all of that code, put all the paper in a big pile, douse it with lighter gas, and set it on fire.

And it makes me angry for the same reason that guy is angry about the bullshit tetrachromat online test. It spreads bad practices, bad knowledge, and people don't care about it.

Now that's just but one example of why I hate Arduino. That's a fresh example I stumbled upon while searching for keypad material today, but quite frankly, if I were to start listing all of the bad things that are in Arduino, I'd spend more time than it takes to write my own SDK. So I won't bother.

Fatal error: Uncaught Error: [] operator not supported for strings in /var/www/blog/inc/core/class.dc.postmedia.php:61 Stack trace: #0 /var/www/blog/inc/core/ dcPostMedia->getPostMedia(Array) #1 /var/www/blog/cache/cbtpl/29/59/2959320ca61719bec433f91e69098e86.php(137): dcMedia->getPostMedia('56', NULL, 'attachment') #2 /var/www/blog/inc/libs/clearbricks/template/class.template.php(268): include('/var/www/blog/c...') #3 /var/www/blog/inc/public/class.dc.template.php(231): template->getData('post.html') #4 /var/www/blog/inc/public/lib.urlhandlers.php(122): dcTemplate->getData('post.html') #5 /var/www/blog/inc/public/lib.urlhandlers.php(523): dcUrlHandlers::serveDocument('post.html') #6 /var/www/blog/inc/libs/clearbricks/url.handler/class.url.handler.php(166): dcUrlHandlers::post('2015/03/12/Here...') #7 /var/www/blog/inc/public/lib.urlhandlers.php(187): urlHandler->callHandler('post', '2015/03/12/Here...') #8 /var/www/blog/inc/public/prepend.php(156): dcUrlHandlers->getDocument() #9 /var/www/blog/ind in /var/www/blog/inc/core/class.dc.postmedia.php on line 61