The Smarter Home Club is dedicated to learning, teaching, and sharing, so our next blog series is dedicated to micro-controllers. You don’t need to know how to build circuits with micro-controllers or to program them in order to enjoy the benefits of home automation. There are easy to install products that cover the majority of things you will want to do – but not everything. Learning how to use various dev kits and micro-controller prototyping boards will give you a means to build tools for the projects that commercial products don’t address, as well as helping you understand what goes on behind the scenes with the automation products that you buy and install.
A key point here is that you read with your eyes but you learn with your hands.
When you want to learn to build circuits or you want to learn to program a micro-controller, plug one into a breadboard. Plug in the components for the circuit you want to learn about or use. Having the hardware and a set of instructions that lets you build it on your own desk will help you learn quicker and more completely than just reading words on a page. Accordingly, each article in this series will include a hardware list for the project.
I’d like to point out that the list will contain affiliate advertising links – this allows us to earn a small fee by linking to the sites selling these products. The benefit to us is that we’ll be able to offset part of the cost of obtaining products in the projects and write-ups that we share with you – it isn’t going to make us rich, but it sure beats asking for donations!
There are benefits for you, if you use the links. First of all, we’ve been able to find products that are very reasonably priced, which are available from Amazon with Prime shipping, and we’ve even got coupons for you! Finally, we’ve already done the testing and know how well the products perform. No guess work when you’re already trying to learn something new.
The TINY board we’re starting with is an Arduino Nano clone with 8 analog and 14 digital pins (digital pins include TX, RX, and 6 PWM pins). It’s 5v, powered by a Mini-B USB port. The USB to serial chip is older – CH340 USB UART chip – but that’s a simple driver install, at worst.
It uses the ATMEGA328P chip, which has 32k of Flash. That’s plenty of room for the beginning and intermediate projects that you’ll work on with the board, though more advanced (larger) projects will require a board with more flash.
One feature you’ll appreciate is that the headers are already soldered.
Here’s a link to purchase the Nano:
This is actually a five pack of the boards. I’ve found that I prefer to have multiples of a board so that I can run multiple projects without tearing down an existing one. Also, when you are building on, expanding a circuit you already know, having a working example beside the one you’re looking at REALLY helps.
As I mentioned earlier, we’ve also got a coupon for this product, courtesy of our friend Cola at eMakefun – enter 8H4NTIYN at checkout for a 20% discount.
Once you’ve got the boards in hand, you’ll want to make sure that they’re working, so we’ll get you started by downloading the Arduino IDE – this is the program that you’ll use to write programs for your Arduino (the programs are called sketches) and then upload them to run.
Driver:
If you are using OSX or Linux, message me for help getting instructions on installing your driver. Windows 10 should obtain the CH340 driver automatically. If it doesn’t, or you’re using any other OS and haven’t installed the driver yet, here’s a link:
http://www.wch.cn/downloads/CH341SER_EXE.html
In Windows, you can determine if you need the driver quickly – plug in one of your boards. If Windows has the proper driver installed (or obtains it), then you’ll see a Windows message box installing the driver, which will disappear when the board is set up and ready to use. If the message box reports that no driver was found, you’ll need to download and install the driver above.
Also, please note that you’ll see one solid red LED (Power) and one blinking red LED (L) at this time.
Once you’ve got the driver installed or determine you don’t need it, you can verify everything was set up correctly while also determining the COM port assignment – which you’ll need in the following section. Right-click “My Computer,” “This PC,” or “Computer” on your desktop, then select Properties. Click “Device Manager” and expand the Ports (COM & LPT) section. Look for the CH340 port in the list of ports.
Now that you’ve verified that you’ve got the driver installed and verified it works, you need the Arduino IDE:
https://www.arduino.cc/en/Main/Software
Go to this page and select the version appropriate for your OS. As of today, the current version is 1.8.9, but newer versions should work the same way, basically.
When the install completes, click the TOOLS menu and select PORT. Set your Port to the COM# you found for the CH340 earlier. Next, click TOOLS again and, this time, select the “Board” menu, just above PORT. This board uses the bootloader for the Arduino Pro Mini, so select “Arduino Pro or Pro Mini.” This will make no difference to the code that you write, but, unless you select this option, it will not compile your sketch properly.
Click the File menu and select Examples. Select Basics and then Blink. A new Arduino IDE window will open with the Blink sketch loaded. Look for two lines that each state “delay(1000);” and change the value 1000 to 250 for both lines.
Click the “Upload” button on the toolbar. This will start the process of compiling the code and uploading it to your board. You should see the first (RX) and fourth (TX) red LEDs blink/flash quickly while the code is uploading. Once the IDE indicates “Done uploading,” press the Reset button in the center of the board and hold it for 3 seconds. Release the button and you should now see the red LED blinking rapidly.
The board comes with the Blink sketch loaded by default. You reduced the delay between turning the LED on and turning it off to 1/4 second each, down from 1 second. 1000 milliseconds equals 1 second!
You now have five working micro-controller boards (for less than the cost of one name brand board) and have verified that it works. In our next entry, we’ll cover the various pins of the Nano, how to use it with a breadboard (while connected to your PC or powered by a battery), as well as some of the other things you need to know to program this little beasty!
SmarterHome.club is the website for our Facebook community, The Smarter Home Club – which is an umbrella for all kinds of smart home technologies – home automation, security, custom electronics, weather stations, alternative energy, you name it. DIY focused.
If you’re interested in joining the Smarter Home Club’s Facebook group, please follow this link:
2 Replies to “Learn To Program Arduino”
Comments are closed.