Arduino, Programming

Arduino + DS1307 RTC

Another demo for interfacing an Arduino with the DS1307 Real Time Clock. The board I used (see here) also has an integrated 24C32 32K EEPROM which we won’t worry about in this demo.

Here’s a picture of my setup:

IMG_20151121_202254

Materials Used:

  • Arduino Uno R3
  • 16×2 LCD Shield
  • DS1307 board (I used this one) but you could use this one too
  • CR2032 button cell

Wiring details:

(NOTE: If you’re using the same board as me then wire to the side of the board with the pins SQ, DS, SCL, SDA, VCC, GND & BAT)

  1. Uno’s 5V (via LCD Shield) to RTC’s 5V
  2. Uno’s GND (via LCD Shield) to RTC’s GND
  3. Uno’s Analog Pin 4 (via LCD Shield) to RTC’s SDA
  4. Uno’s Analog Pin 5 (via LCD Shield) to RTC’s SCL
  5. Leave the other pins unconnected
  6. Put the button cell in!

You can find the code here. And voila! 🙂

Advertisements
Arduino, Programming

Arduino + HR-SR04 Ultrasonic

I wanted to try an Ultrasonic sensor so I bought the cheapest one I could find, the HR-SR04. I used this tutorial to learn about the ultrasonic. Basically I thought the Ultrasonic would provide an analog signal with the distance…well I was wrong. Distance is calculated based on the time taken for an echo signal to be sent and received.

Here’s a picture of my setup.

IMG_20151121_160922

Materials used:

Wiring is easy:

  1. Uno’s 5V (via LCD Shield) to sensor’s 5V
  2. Uno’s GND (via LCD Shield) to sensor’s GND
  3. Uno’s Digital Pin 0 (via LCD Shield) to sensor’s ECHO
  4. Uno’s Digital Pin 1 (via LCD Shield) to sensor’s TRIG

You can find the code here. And voila! 🙂

Arduino, Programming

Arduino IDE Alternatives

Ok the original Arduino IDE is good but not great. It’s pretty basic as it’s intended to be. I needed something better, something advanced. I didn’t try every alternative out there. I tried using Eclipse (it’s actually an eclipse plugin, see here) but I couldn’t get it work. I believe it didn’t work because I needed 32 bit Java. Anyways, I tried Visual Micro. This is something I liked. It’s also a plugin for Visual Studio. (FYI Visual Studio now comes in a free community edition, see here) Two things I didn’t like:
1) Creates too many files, that’s just how Visual Studio works. It creates several folders and files which I don’t need.
2) Some of the compilation errors didn’t show up. I was pulling my hair trying to figure out the cause of the error. I eventually figured out it after I compiled it using the original Arduino IDE.

The other “problem” for me was that I’m using a PC and laptop (it’s one of those convertible tablet/laptop) for development. I wanted to same the software on both systems. I didn’t want to install a big IDE like Visual Studio (with Visual Micro) on my laptop (it doesn’t have much space).

So I have decided to use Notepad++ for development and then use the original Arduino IDE with the “External editor” option activated.

Arduino, Programming

FTDI RX TX lights are reversed

I bought an XBee USB Adaptor (looks exactly this one but I bought from eBay) with an FTDI chip for USB to Serial comms and I noticed that the RX & TX lights are reversed. Don’t worry it can be fixed 🙂

  1. Download the “FT_Prog” program from here.
  2. Extract and install it
  3. Connect your FTDI board to your PC
  4. Run FT_Prog
  5. From the FT_Pro window, click on “Devices” and then “Scan and Parse”
  6. Go this:
    FT_Prog
  7. Notice C0 & C1 has RXLED#  & TXLED# (your setup might be the other way), swap them around.
  8. Click on “Devices” and then “Program”. This will bring up a new window.
  9. Click the “Program” button. It only takes a few seconds. It will provide a success message at the bottom of the window. Don’t ask me what to do if it shows an error message (sorry!).
  10. Press “Close” and close FT_Prog.
  11. Unplug the board from your PC and plug it back in.
  12. Voila! 🙂

NOTE: Each time you flash the FTDI, the port number changes and the serial number.

Arduino, Programming

Arduino Uno and Nokia 5110 LCD

If you want to know how to wire & program a Nokia 5110 LCD using an Arduino Uno, you have come to the right place 🙂

Here are the parts needed:

  1. Arduino Uno (Qty: 1) (http://core-electronics.com.au/arduino-uno-r3.html/?acc=7f39f8317fbdb1988ef4c628eba02591)
  2. Nokia 5110 LCD (Qty: 1) (http://core-electronics.com.au/graphic-lcd-84×48-nokia-5110.html/?acc=7f39f8317fbdb1988ef4c628eba02591)
  3. Logic Level Converter (Qty: 2) (http://core-electronics.com.au/logic-level-converter-module.html/?acc=7f39f8317fbdb1988ef4c628eba02591)
  4. Lots of connecting wires
  5. USB cable for the Arduino Uno (USB A to USB B)

Here is my setup (made with Fritzing):

Uno5110_bb

Here are the software/libraries I used:

  1. Arduino 1.0.4
  2. Adafruit’s base library for the Nokia 5110 (https://github.com/adafruit/Adafruit-PCD8544-Nokia-5110-LCD-library)
  3. Adafruit’s graphics library for the Nokia 5110 (https://github.com/adafruit/Adafruit-GFX-Library)

Here are the instructions to run the sample code:

  1. Extract the Adafruit libraries into “..\arduino-1.0.4\libraries\”.
  2. Your directory structure should look like this:
    \arduino-1.04\
    \arduino-1.04\libraries\
    \arduino-1.04\libraries\Adafruit_GFX\
    \arduino-1.04\libraries\Adafruit_GFX\Adafruit_GFX.cpp
    \arduino-1.04\libraries\Adafruit_GFX\Adafruit_GFX.h
    \arduino-1.04\libraries\Adafruit_GFX\glcdfont.c
    \arduino-1.04\libraries\Adafruit_GFX\license.txt
    \arduino-1.04\libraries\Adafruit_GFX\README.txt
    \arduino-1.04\libraries\Adafruit_PCD8544\
    \arduino-1.04\libraries\Adafruit_PCD8544\examples\
    \arduino-1.04\libraries\Adafruit_PCD8544\examples\pcdtest\
    \arduino-1.04\libraries\Adafruit_PCD8544\examples\pcdtest\pcdtest.pde
    \arduino-1.04\libraries\Adafruit_PCD8544\Adafruit_PC8544.cpp
    \arduino-1.04\libraries\Adafruit_PCD8544\Adafruit_PC8544.h
    \arduino-1.04\libraries\Adafruit_PCD8544\license.txt
    \arduino-1.04\libraries\Adafruit_PCD8544\README.txt
  3. Start the Arduino IDE
  4. From the File menu, click on Examples, then “Adafruit_PCD8544” and “pcdtest”.
  5. Find the following line:
    Adafruit_PCD8544 display = Adafruit_PCD8544(7, 6, 5, 4, 3);
  6. Change it to:
    Adafruit_PCD8544 display = Adafruit_PCD8544(13, 11, 7, 6, 5);
  7. Compile and download (or “upload” in the Arduino world).
  8. Done! You should see various graphic examples being displayed.
Arduino, Programming

Use Arduino Uno as an AVR ISP to burn the bootloader onto a SparkFun Pro Micro 5V

I have a SparkFun Pro Micro 5V running an older bootloader. In order to burn a new bootloader you need an ISP (In-System Programmer). You can buy an AVR ISP and use that, or you can use an Arduino Uno as an AVR ISP 🙂

Here are the instructions:

We turn the Uno into an ISP:

  1. Connect your Uno to your computer.
  2. Run the Arduino programming software.
  3. From the File menu, select Examples and click on “ArduinoISP”.
  4. Download this sketch to your Uno.

Now we wire in the ProMicro to the Uno. Don’t connect the ProMicro to your computer! And connect the following pins together:

  1. Uno Pin GND to ProMicro Pin GND
  2. Uno Pin GND to ProMicro Pin GND & GND (located on the other side of the board)
  3. Uno Pin 5V to ProMicro Pin VCC
  4. Uno Pin 13 to ProMicro Pin 15
  5. Uno Pin 12 to ProMicro Pin 14
  6. Uno Pin 11 to ProMicro Pin 16
  7. Uno Pin 10 to ProMicro Pin RST
  8. Remove the wire to VCC and put it back in. (I had some errors where didn’t work until I did a “reset” on the ProMicro)

We burn the bootloader:

  1. Close the Arduino programming software
  2. Download the new bootloader for the ProMicro (It’s the Add-on link located in https://www.sparkfun.com/products/11098?)
  3. Unzip that folder into “C:\…\arduino-1.0.4-windows\arduino-1.0.4\hardware”.
  4. Run the Arduino programming software.
  5. From the Tools menu, select Board and click on “SparkFun Pro Micro 5V/16Mhz”.
  6. From the Tools menu, select Programmer and click on “Arduino as ISP”.
  7. From the Tools menu, click on “Burn bootloader”.
  8. Wait a few minutes. You should see the RX & TX LEDs flashing on your Uno during the burning process.
  9. Done!

If it doesn’t work, the error is displayed in the console. If it works, it won’t show a message in the console but in the area just above it, “Done burning bootloader”.