Skip to main content

Getting Started With Arduino

Arduino Programming

I have an old Arduino Duemilanove board that I bought a long time ago and have since neglected.

This is a very old board, first released in 2009 and no longer available except maybe on Ebay.

/images/arduino/arduino-duemilanove.jpg

To get started with using this microcontroller you have to download the Arduino IDE.

Arduino IDE

Download the Arduino IDE and install. It is likely that you will have to add your user account to the dialout group and log in again. I also had to make the /dev/ttyUSB0 device group read+write-able. There may be other ways to do this but I used reliable old chmod g+rw /dev/ttyUSB0.

A good hello world project is to upload the blink sketch. This makes the onboard LED flash, which confirms that you are able to do something with the microcontroller.

I modified the sketch slightly to make the LED stay on for three seconds, just to be sure .

/*
  Blink

  Turns an LED on for three seconds, then off for one second, repeatedly.

  http://www.arduino.cc/en/Tutorial/Blink
*/

// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(3000);                       // wait for a second
  digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);                       // wait for a second
}

Click the Verify (tick mark) and Upload (right arrow) buttons and the sketch should upload to the board and the LED should start blinking.

/images/arduino/arduino-ide-closeup.png

Trouble

I had a lot of trouble getting this to work at all. There are a lot of basic things that you have to get right.

  • As mentioned, fix group access permissions to the USB device.

  • Make sure you have selected the right board from the Tools > Board menu, it won't be auto-detected for you.

/images/arduino/arduino-ide.png
  • Select the right processor from the Tools > Processor menu. It might help to have a close look at the chip on the board to work out which one it is.

/images/arduino/arduino-duemilanove-closeup.jpg
  • If this all fails, you can turn on additional debugging output from File > Preferences > Show Verbose Output and start searching Stack Overflow.

Welcome Helianthi

Happy New Year

A New Laptop For A New Year

I went to JB Hi-Fi and after much indecision and wandering up and down the aisles, bought an HP Laptop. As I was planning to use it for Linux and probably wanted dual boot with Windows, I selected one with a larger hard disk drive.

I played with Windows 10 on the laptop and was gripped by buyer's remorse. I became quite grumpy. What was I going to do with this thing? After fiddling with a few settings to make it feel more homely and not succeeding much I set about installing Linux.

I took the easy choice and decided on Ubuntu, downloaded the Ubuntu 18.04.3 LTS via bittorrent and flashed it onto a USB stick.

Make Some Room

The Ubuntu installation is smoother if there is an empty disk partition for it. The last thing I did in Windows was to use the Disk Manager to shrink the main disk volume.

Booting To BIOS

The next step was to restart and press the escape key while restarting. This shows a menu that lets you press [F10] to get into the BIOS. In the BIOS you need to disable secure boot.

Install From USB

Installing Ubuntu from the USB stick proved to be very smooth. It was just a matter of clicking the buttons and waiting. Almost all the hardware was supported by default.

Installing Drivers For Wifi Card

There is one little bit of traditional Linux software tinkering. The laptop turns out to have a wifi card that is not supported by the default install of Ubuntu.

First, to find the make of the wireless card:

$ lspci -v | grep -i network
03:00.0 Network controller: Realtek Semiconductor Co., Ltd. RTL8821CE 802.11ac PCIe Wireless Network Adapter
  Subsystem: Hewlett-Packard Company RTL8821CE 802.11ac PCIe Wireless Network Adapter

This particular Realtek model (RTL8821CE) required an alternate driver.

First, prepare to install some software:

$ sudo apt-get install linux-headers-generic build-essential git dkms

Install Realtek Driver

The driver for this wireless card is maintained by Tomás Pinho. The software must be downloaded and installed, but this is straightforward:

$ git clone http://github.com/tomaspinho/rtl8821ce
$ cd rtl8821ce/
$ chmod +x dkms*.sh
$ sudo ./dkms-install.sh
$ sudo reboot

Reboot and configure your wireless adapter.