Tag Archives: making

How To Get the Arduino Time Library up and going

I’m working on a new arduino project at the moment and for it to work, I need the arduino to be able to tell the time. 

To make this work, I decided to use the Arduino Time Library (specifically the updated Time library). I was going to use the TimeSerial sketch. I expected this would be an easy task, and indeed it did look straight forward, with nice simple functions to call up the hours (hour()), minutes (minute()) and seconds (second()).

However, despite this, I really struggled in working out what the actual time was. And I’m not sure if it was just that it was late at night, and my brain wasn’t functioning at its fullest, but I really could not find an easy guide anywhere. After lots of trial and error I worked it out, and here, for you, is the tutorial of how to flipping get the flipping Time Library to work.

Know the software to use

I didn’t get this, but you will need to use both the Arduino IDE and Processing. For some reason I thought it was the case that you use one or the other. The Arduino IDE talks to the arduino, and Processing is responsible for getting the time.

Know the programs to run

You will need to run two programs: TimeSerial (in Arduino IDE) and SyncArduinoClock (in Processing). Get these both opened in their respective software.

Image

Edit the Processing sketch

Now what’s going to happen, is Processing is kind of going to “jump start” the Arduino and give it the time at a certain time point. The arduino is capable of keeping time (if it has power) once it knows what the time is initially. So you need to get Processing talking on the right port. When I opened it, the line “public static final short portIndex = 0;” was set to 0, which is a bluetooth port. When you run it, it will try and talk to bluetooth, which wasn’t useful to me. But what was useful, was that in the terminal window at the bottom of Processing, it told me what was on each of the ports. Reading this I saw this line “[4] “/dev/tty.usbserial-A600bMH2″” and so changed the line of code to read “public static final short portIndex = 4;” so that it was now talking to the right port.

Image

Start your engines (in the correct order)

This step got me for a while, you need to start your sketches running in the correct order. If you start Processing first then Arduino complains that it can’t get to the port it wants to. So, start the TimeSerial arduino sketch, in Arduino. If you open the Serial viewer, you’ll see a message that says “Waiting for sync message”. This is because it is waiting for a message from Processing.

At this point, start the SyncArduinoClock Processing sketch. A box will hopefully appear that says “Click to send time sync”. Click it.

Image

You should now see in the Arduino serial monitor that there is a lot of weird text appearing. That is because it’s trying to count for itself, and also receiving sync messages from Processing. Go back to Processing, and stop that sketch running. And back to Arduino, and hopefully, you should be getting a nice neat print out of the date, and time every second. 

You’ll never be late for anything again.

Hope that helped someone avoid the long hours of struggle trying to understand how to get the stupid thing to work!

Advertisements
Tagged ,

Controlling Number Entry Using Sifteo Cubes

As you have probably gathered, I am really interested in Number Entry. I’ve been thinking a lot about how we enter numbers – whether we think of them as a series of digits, or as full numbers. This has implications for the way we might ask people to enter numbers on an interface.

I was given an opportunity to test this out recently at the CHI+MED interface hack day. Last Friday (9/8/13) a group from CHI+MED came together at Swansea university to hack some interfaces to investigate novel number entry methods.

I got a chance to play with some Sifteo Cubes. Sifteo Cubes are fun little blocks with screens that are aware of which other blocks they are next to. This allows for some fun physical interaction, with the user picking up and moving the blocks around.

At a previous idea generation session, we came up with the idea that you might want to let a user enter numbers on the sifteo blocks using both a digit and number strategy. The difference between the two meaning that you could either control the number digit-by-digit (that is, incrementing the digit 9 in the number 659 would result in 650) or by controlling the whole number (that is incrementing the digit 9 in 659 would result in 660).

Using one Sifteo block as the “controller” and the other two as the numbers, I created a system to allow the user to enter numbers using any strategy they like. See the video for an example. You can see that they can control each block separately. When the blocks are joined, the entire number can be incremented (by placing the control block to the left or right) or just the digit can be changed (by placing the control block above or below).

Programming the Sifteo blocks was an interesting challenge. You need to program in C++ (a language I haven’t looked at for a few years) and at first, reading the example code was a bit daunting. But after a while I managed to hack it together. The really strange thing about doing this was working with images. Unlike many programs where you can directly write text (or numbers) to the screen, when programming for the Sifteo cubes you are dealing with lots of static images, and swapping them in and out as you need. Meaning in my application in the video, I have 10 different image files, one for each digit.

I enjoyed the experience of hacking and playing with the blocks. I think there are some interesting questions that could be explored using them. We will see!

Tagged , , ,