Categories
Uncategorized

Development with Resistance

As you may know, I sell a variety of USB controllers (on Etsy and my own shop) and I accept custom orders where I work with the customer to build (and program) what they want or need. So last year someone got in touch with me and said “Your Dual Button looks great! I need it with a 2.5mm stereo jack though, and it’s going to control some [REDACTED] equipment.”

So this was not a USB controller, but they liked the form factor of my product. Well, no problem. I do custom. I got as much detail as I could about the device they had (which was not working anymore) and asked for photos. There was a resistor wired into one of the buttons, so I asked the customer to check it with a meter to get the value. He couldn’t quite figure it out, but we made some guesses based on the color bands in the photo and I came up with a solution.

With the 2.5mm stereo jack we determined which of the TSR (Tip, Ring, Sleeve) parts were ground, and each of the buttons, and which button had the resistor on it. One button supplied full voltage and the other a lower voltage. I didn’t find out too much about the extremely expensive equipment it was connecting to, but I didn’t need to.

I came up with an easy way for the customer to swap the resistor, and even sent spares of various values in case we didn’t guess correctly. I think it worked fine with our “guess” resistor, so maybe the equipment just looks for full voltage versus a lower voltage. Who knows? I don’t work in the [REDACTED] field.

I often find these projects fun and a little challenging. I probably don’t always cover the time I put into them, but often they’re a good learning opportunity and sometimes turn into a product or repeat business.

Categories
Uncategorized

Learning to Code

Copying and Pasting

I saw many friends share this amusing image of a fake O’Reilly book titled “Copying and Pasting from Stack Overflow”, and if you’re not in on the joke, Stack Overflow is a web site where you can post programming questions and get answers to those questions. It’s also a site (like many others) where people who are not sure what they are doing grab bits of code from when they are not 100% sure what they are doing. (And if you don’t know about O’Reilly, they publish technical books, many about programming.)

This is the first semester I’ve taught a class that includes programming. I was upfront with students about how I’ve learned to write code over the years, and that includes looking at examples, using existing code, and (eventually) reusing my own code. I didn’t force them to type out each line of an Arduino sketch because I didn’t think it was completely necessary. They already know how to type, and once I showed them how to hit the compile button, they learned about syntax errors. Occasionally in class I’d demo things by writing code on the fly and inviting them to type up what I just typed, and to play around with the values, add more lines, etc. (I showed them the “Examples” menu early on, which contains plenty of useful code to get started with.)

Here’s something that may be news to some readers – I’m not a great programmer. I’m a hacker, and I can write enough code to get by, but more importantly I can find enough sample code and examples and tutorials to write the code that I need to do what I want to do. I think that’s the key to things.

If you’ve ever heard the expression “To be a great writer, you need to be a great reader” then perhaps this also applies to programming, and reading code is an important part of writing code.

Now, with all that said, I still expect students to learn some of the basics of writing code and understanding it. If at the end of the semester all they’ve done is copied & pasted code that someone else wrote, and by some miracle it compiles and runs and works for their project, that’s still sort of good, but not quite as good as having a basic understanding of what exactly those lines of code are doing.

In the meantime, keep copying code, and pasting code, and while you’re at it, try to read it and understand it.

Categories
Uncategorized

PHP error_reporting

PHP (Once again a note for myself, but if you find it useful, well, you’re welcome!)

After a PHP upgrade, I noticed at least one bit of PHP code one the server wasn’t working (the TextLinkAds plugin for WordPress) so after a bit of digging around in php.ini, I found that this line was uncommented:

error_reporting  =  E_ALL

Which was causing warnings to spit out when some PHP scripts were run. I commented that line, and uncommented this line instead…

error_reporting = E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR

…for a little bit less error reporting/warnings about things, and that fixed it.

I’m sure this is not a cure-all, as another site with the same plugin always worked fine, and was never affected, but still, I didn’t really like seeing those warnings (which I believe are harmless, but they may need investigating anyway.)