Arduino LCD Keypad Shield – Basic Menu System

LCD1After recently purchasing an LCD and Keypad Shield for my Arduino Uno. I thought I best test it out and write a quick sketch to use with it.

The shield has a 16×2 (LCD1602) LCD and 6 Button Keypad , extremely useful for controlling your projects without hooking the Arduino board up to anything. I believe this cost me just under £4 delivered and is well worth the money.

I have made a basic options selection menu which will allow you to scroll through a list of entries and select one of them, using the least amount of screen updates. It doesn’t yet support sub-menus, but it’s dead easy to implement using this code found below.

Click here to read more..

Arduino Open Source Electronics Platform – What is it?

Arduino Uno R3You’ve probably noticed that quite a few posts on here talk about an Arduino, however we haven’t really gone into detail about what one is or where to get one from.

An Arduino is an open source platform that is based on a microcontroller and an easy to use development environment for building electronic projects. The amount of uses for an Arduino is infinite, you use pins on the board to communicate with other hardware such as sensors, motors, lights, switches, and other circuits or systems.

The development environment for the Arduino is also open source; the programming language is based on Wiring – The IDE is downloadable from the Arduino.cc website and is available for Windows, Linux and MAC OSx.

So, how do I get an Arduino?

You have a few choices here. The first one is if you’re familiar and comfortable with building circuits and have experience with electronics you can build your own. The Arduino is an open platform and there are plenty of guides available to build it from scratch.

The other option is to buy it from the Arduino.cc store, or official reseller. You can normally just buy this as an individual product, or get a kit if you need the additional components. The third option is to buy a cheaper, compatible version of the Arduino – again, as this is open-source there is a number (if not hundreds) of manufacturers. Keep in mind the last option that you get what you pay for (e.g. sometimes cheaper/lower quality parts)

You can find a link to the Arduino Store here. Or a list of distributors here.

There are multiple versions and types of Arduino

There are many types of Arduino, the version you start with entirely depends on your experience and preference, or if you have a project in mind already, your requirements. So what versions of Arduino are there?

 

Which one is right for me?

This all depends on what you want to gain from it. If you’re just starting out the Arduino Uno is a great product to begin with. This will allow you to get to grips with using an Arduino, there are also a good variety of shields available.

If you have any experience with programming then that will be a huge advantage when working with the Arduino.

Shields are extra boards that fit directly on top of the Arduino, some examples are of Ethernet Shields, Motor Drivers, Relay, Proto Shields, LCD Shields, Sensor Shields.. there are a lot.

How can I learn?

You can learn and download resources from hundreds of websites (this one included) but the best place for information is the Arduino.cc website and Forums. Check out the Getting Started Guide linked here if you’re a beginner, this will allow you to understand some basic concepts of the Arduino.

There is much more to talk about, I haven’t even covered 1% of what the Arduino is and can be used for – Searching for Arduino projects into Google or Youtube will give you some idea of the vast array of uses for it. Or if you prefer to learn by reading then Amazon have a huge collection of electronics, microcontroller and Arduino specific books available.

I hope that’s covered some of the questions people may have about our Arduino posts! There will certainly be more on here soon.

What is a Raspberry PI? – A quick review.

rpiThe Raspberry PI is a miniature low cost computer that can be used for a wide range of projects and entertainment. You may have seen a lot of press around the Raspberry PI as it has had quite a lot of exposure.

It’s a great way to learn Linux computing and to dive into the world of programming – There are many resources available online such as YouTube and the Raspberry Pi Forums.

First Impressions

The first thing you’ll notice is that the RasPi comes with no case, it is a circuit board with components on, this may come as a shock if you’re used to just going out and buying a computer. Many cases of different shapes and sizes are available online, most likely from the retailer you purchased the RasPi from.

No keyboard, mouse or wireless access is provided unless you’re buying a kit that includes these items. There are 2 USB ports (Model B) on the board which you can use, or you can use a powered USB hub if you need more ports.

There is no on/off switch as soon as you plug in power it will attempt to boot. You will however need an SD Card (not provided) with an operating system already set up. There are various Linux distributions available for download from the Raspberry Pi website – as well as community developed projects such as XBMC, OpenElec for media servers.

There are currently 2 models of the Raspberry Pi – The Model A and Model B the differences are below (from the RasPI FAQ)

The Model A has 256MB RAM, one USB port and no Ethernet (network connection). The Model B has 512MB RAM, 2 USB ports and an Ethernet port.

What’s the Specification?

CPU: 700 MHz ARMv6 Processor
GPU: Broadcom VideoCore IV 250 MHz
Memory: 512MB (Model B) 256MB (Model A)
Expansion: 2x USB2 (Model B, 1x Model A) – SD Card Slot
Video Output: HDMI and Composite RCA
Audio Output: 3.5mm Jack and HDMI
Network: 10/100 Ethernet (8P8C) (Model B Only)
Size: 85.60 mm × 53.98 mm (3.370 in × 2.125 in)

What Distributions are available?

Many popular and well-known distributions are available. some of which outlined below. These are just a taste of what is available. Check out the Raspberry Pi website for more information.

  • Arch Linux
  • Raspbian OS
  • Debian
  • Gentoo
  • Fedora
  • RISC OS

What can I do with a Raspberry Pi?

The list is endless really, you can’t eat it – but the Raspberry Pi provides GPIO access for interfacing with other hardware, it can be used for learning electronics or connecting additional third-party modules. There is also an SPI interface for connecting things such as the official RasPi Camera Module.

It’s basically a Linux computer and most if not all things you can do with a regular Linux computer you can do on the Raspberry Pi. It’s convenient to just plug in to the TV or monitor and have instant access to a system, the best part is if you do manage to break the operating system it only takes minutes to fix, as the OS is stored on an external card.

Some example projects include attaching the Pi to a weather balloon, media centres, file servers, a web server, home automation, electronic projects and many, many more…

Final Thoughts

If you’re into computers or just want to learn how they work then a Raspberry Pi is for you. It’s a great educational tool for learning and for the price they cost it’s worth having a look and trying it out. Check out the Raspberry Pi website for more information and where to buy.

 

Fritzing – Open Source Electrical Design Software

fritzing-logoFritzing is an Open Source piece of software used for the design of electrical circuits. Whilst Fritzing doesn’t do circuit simulation, it does design very, very nicely. You have probably seen some of the Fritzing graphics posted on the Arduino.cc website which is what initially caught my eye.

First impressions upon loading is that it has a clean, polished layout with the interface being snappy and switching between tabs very efficient.

There are 3 layouts in which you can see your design: Breadboard, Schematic and PCB. You can switch between any one of these whilst designing, I have included screenshots of each layout below (this is the Arduino Blink LED example)

Fritzing            Fritzing5            Fritzing6

So, what’s so good about it?

The look and feel of the designs it produces look extremely professional, the PCB Layout is ideal for posting up how things should be connected and linked together and I can see myself using this on this website as well. Some other notes below:

  • High quality illustrations, including the Arduino (pictured above), breadboards and many components.
  • Open Source software, it’s completely free to download and use (check the License information first though!)
  • Missing some parts? You can create your own components and save or share them using the built-in parts editor.
  • A variety of export options, including PNG, PDF, SVG and also Etchable export formats.
  • The PCB view is useful (and cool!) for displaying your circuits.
  • There is a service to manufacturer your PCB design, however I have not used this service.

And the bad?

Well, not really any bad remarks at all, only some feature requests. How good would this be with circuit simulation? Absolutely amazing, that’s what. Plus maybe an installer so I have start menu/desktop short-cut created for me but that’s not exactly important at this stage.

This is still BETA software so you can expect the occasional bug here and there, but plenty of software updates.

More Information & Where to Download

As Fritzing is written with C++ and Qt it has support for Windows, Linux and MAC. You can also download the source code on the Fritzing website. Keep in mind that the source code of Fritzing is licensed under GNU GPL v3, the documentation and breadboard view graphics under CC Attribution-ShareALike. Please do leave credit when creating and sharing your designs online.

I haven’t been a Fritzing user for very long, so my apologies if I have missed something vital. This has got to be one of the best, free design tools available at the minute.

You can download Fritzing from fritzing.org  you won’t be disappointed. There are various tutorials, guides and FAQs on the Fritzing website.

Arduino – sorting array integers with a bubble sort algorithm

As it happens, I needed to sort an array of integers in ascending order and also find the minimum and maximum number from the array on my Arduino. I decided to knock up a quick bubble sorting function which you can find below.

Bubble sorting is probably one of the easiest and quickest (to write, not actually sort!) algorithms to produce in C. It works by iterating through the array of values comparing pairs and swapping them around if need be, it then performs the same action again until no swapping is needed. You can read more on the Bubble Sorting algorithm by clicking here.

The above Arduino sketch has debug Serial output which should look like the following one uploaded:

bubble

This code isn’t limited to the Arduino, there are no special function requirements needed and should work in any C based application. The only thing that you may want to change is finding the size of the array instead of having it static however I did not need this as I knew how many elements I needed.

Arduino based task scheduler/threading functions

ardIf you’ve used the Arduino before then you’ll know that any code you write in the loop() function is executed on every cycle. But what happens when you have code that needs to run at certain intervals? A delay() will just cause that iteration of loop() to hang and pause.

Arduino released a tutorial BlinkWithoutDelay which introduced the concept of checking the “uptime since last boot” and comparing that to make a basic function scheduler.

The code below basically does the same job, except it’s cleaner and easier to manage. This is by no means original, there have been hundreds of productions of this code, this is just one way to go about it.

The naming structure is shown below, instances of the Timer are prefixed with t_FunctionName to indicate this is a timer.

Instead of checking a single variable for the current milliseconds since boot, this will create a new instance of a structure that can be used to store timings for functions. This way you can easily change when to run a certain portion of code without digging through the sketch or remembering which variables contain the correct values.

The loop() portion of the sketch should be kept clean and only be checking the cycles of the functions from the structure. There should be no need to place any program code inside of the loop() function except for these checks.

This should provide the following benefits:

  1. Enable you to run code every [x] milliseconds or [x] seconds.
  2. Structure the program so that you know when code is running and being able to easily change this.
  3. Have a faster running program. e.g. if you know a portion of code is slower and delaying the loop() you can have this run on a larger interval so it isn’t executed as often.

This code is compatible with all versions of the Arduino and most likely other boards where the language is also based on C.

Fixing erratic LDR values

ldr

After working with a few different sensors hooked up the Arduino, I was experiencing some strange issues where as the value of the LDR would constantly jump up and down within a specific range. I am not sure if this is the quality of the sensor, but it was doing it for all of the LDRs that I have.

I decided that it needed some artificial smoothing in the code to get a useful value. See sample code below for smoothing out LDR values. We need to change the value from an erratic analog value to a digital percentage as an integer.

As you can see, the function takes two parameters samples and sampleInterval The samples is how many times it should query the LDR for the value and the second parameter is how long it should wait before each query.

Depending on the size of the LDR and quality, the min and max smooth value may need to be adjusted (550 and 1023) depending on the range you get back from your LDR.

The function will return an Integer between 0 and 100 depending on the amount of light.

Page 3 of 3123