“Yoda” Conditions

Here’s a creative idea I’d never considered before.  I’ve written code like this, but accidentally, and then it looks wrong so I change it back.  Here’s a quick example:

if ( 42 == myInt )  as opposed to  if ( myInt == 42 )

The former may be better to use because occasionally we all forget to put that second “=” in there, and we accidentally turn our comparison operator into an assignment operator.  Compilers will complain if you try to assign a value to “42”, but not if you try to assign 42 to a variable, and that’ll make it easier to catch your mistake.

LCD Modules

I’ve never built anything with an LCD on it before, but it seems like it’d be useful.  Here’s some good info on creating an project with an LCD and an Arduino:


It’s a library of functions that make it very easy to work with the LCD controller.  The controller has to be compatible with the HD44780 controller’s instruction set, but that’s basically an industry standard.  Mouser has a selection of 20×4 character displays:


Probably most of these are compatible with HD44780, but one brand that I’ve seen a couple good comments on is Newhaven Displays.  Here are two of their products which people say are compatible with HD44780:


The difference seems to be in the background color and input voltage: the first link is 3.3V, the second is 5V.  Here’s some more info from Wikipedia:


And here is Hitachi’s info on the command set for their oh-so-popular chip:


One thing I’m motivated to build with these guys is a computer-controlled thermostat.  I’ll have to have a temperature sensor (thermistor maybe?), perhaps a wireless connection (XBee?), maybe one of these LCDs to describe the current settings, and if there’s an LCD then definitely some buttons to allow setting the temp without firing up a web browser.