arduino/wiring

Multiple time stamp checks on a microcontroller

Sometimes you need to manage multiple events with a microcontroller that all require different timing.  For example, you might want to control a servomotor (which requires a 20 millisecond delay), blink an LED once a second, and read some sensors (which should be read as frequently as possible.  One way to handle this is to keep track of a time stamp for each event.  You constantly read the millis() and if enough time has elapsed since the last time a particular event occured, you do it again.

Continue Reading »

arduino/wiring

Permalink

Fading an LED from a switch

This example uses a digital input to control a fading LED. The LED turns on when the switch goes from off to on, then fades slowly to black.  It illustrates two principles:  the idea of edge detection or state change detection, and the idea of time delay without using delay().

Continue Reading »

arduino/wiring

Permalink

Using an Accelerometer to Sense Which Way Is Up

ITP just got some nifty flat panel mounts that can rotate 360 degrees. They’re very easy to move, it takes only one hand. When I saw them, I thought, “what good is a rotating mount if the content on the screen can’t rotate too?” So I came up with a little system to sense the screen’s rotation. Here’s how to turn those screens into a very big iPhone. Thanks to Michael Dory for his help in coding this and Dan O’Sullivan for the final clue.

The screens have a mac mini mounted on the back to display digital content. I added an Arduino with an accelerometer mounted on it to sense the angle of the screen’s rotation, then sent that data into Processing.  This example doesn’t do much, but the code can be re-used for any Processing application that needs to know the screen’s rotation.

Rory Nugent modified my existing code and made it much better.  I’ve incorporated his changes here, thanks Rory.

Continue Reading »

arduino/wiring
circuits

Permalink

Lantronix Analog Sender

Here’s a short Wiring/Arduino program that waits for a connection to the microcontroller via a Lantronix device, and sends out an analog reading when it’s got a connection.

The Lantronix device is in connectMode D4, and the TX is connected to the Arduino’s RX and vice versa.

Continue Reading »

Lantronix
arduino/wiring

Permalink

Converting an Arduino Diecimila into an ICSP programmer

Kimio Kosaka has made a way to program a virgin Atmega168 without a hardware programmer.  You use a modified version of the avrdude programming software that can access the extra pins of an FTDI USB-to-serial chip, do a little soldering on your Diecimila, and Bob’s your uncle, as the Italians say.


AVR
arduino/wiring
circuits

Permalink

Sensorbase datalogger

Sensorbase.org is an open data repository run by the Center for Embedded Networked Sensing at UCLA. It’s a database of sensor databases. You can upload datasets to it, and you can browse other datasets as well. If you’ve never set up a database before but are interested in logging sensor data, it’s a good tool to get started. If you know what you’re doing already and you need to log a lot of sensor data, or compare it to similar work from others, it’s a convenient tool.

Since I like working with sensors and microcontrollers connected directly to the Internet, I thought it would be useful to be able to put data directly into Sensorbase from sensors connected to a microcontroller, without a personal computer in between.

Continue Reading »

Lantronix
PHP
arduino/wiring

Permalink

Sensor graphing with 3 lines of code!

I’ve been looking for simple ways to graph the data from a sensor attached to a microcontroller lately, because it’s such a necessary activity if you want to look at sensor data over time. Using Apples Grapher program, which comes with OSX, I found a simple way that involves only four lines of code on an Arduino or Wiring microcontroller, and produces graphs like this:

graph.png

Continue Reading »

arduino/wiring

Permalink

iPod control from Arduino or Wiring

Rosie Daniel wrote a nice piece of Arduino code to control an iPod. Rosie used a hacked iPod remote to connect her Arduino to the iPod. The remote’s AUD connection is its data in connection, which is connected to the Arduino/Wiring board’s data out. The iPod’s power (VCC) and Ground are connected to the power and ground of the microcontroller. Then this code works.

Thanks to Rosie for writing this:

Technorati Tags: , ,


Continue Reading »

arduino/wiring

Permalink

Startup Checks

When you’re making a microcontroller circuit that drives a high current load like a motor or an incandescent light, it’s not uncommon to make a mistake and create a circuit that draws too much electrical energy on startup and causes the microcontroller to reset itself constantly. To debug this, it helps to put a routine in your startup() function so you can see when the microcontroller has started up. For example, I often blink an LED three times in the startup. If the LED blinks three times then stops, I know the microcontroller has successfully run the startup and gone into its main loop. If it blinks constantly, I know the microcontroller is continually resetting, so there’s a problem.

Hans Steiner recently showed me his trick for checking for the startup routine on the Arduino: he writes to the microcontroller’s EEPROM, or permanent memory, and reads back the result. Every time the Arduino resets, it’ll increment the EEPROM value. Since this value is stored even when the Arduino is not powered, you’re going to get a new number each time it’s run.

Thanks to Hans for the code.

Technorati Tags: ,


Continue Reading »

arduino/wiring
circuits

Permalink

USBTinyISP

Recently, I’d been trying to re-program some Atmega168’s for use in Arduino modules, and was having no luck using my AVRISP MkII programmer. All appeared to be working, but it kept failing. I even dug into the details of avrdude, and the programmer responded as if it was working but delivered no love.

Fortunately I had on hand a USBTinyISP from Adafruit. Even more fortunately, Limor Fried has written some nice instructions on the programmer and on installing and running avrdude to program with it. What’s nice is that she’s packaged the software well, so you can run it without too much hassle. The only thing I had to learn was how to point avrdude at her custom config file, by using the -C flag, like so:

./avrdude -C avrdude.conf -v -p m168 -e

(etc)

Even nicer, David Mellis is including support for this programmer in Arduino 0010, so that I can burn new bootloader firmware onto the chips using it without needing to touch the command line app.

Even nicer still: her programmer’s cheaper than the AVRISP mkII (of which I have blown up a few). I may blow this one up in time too, but I’ll be able to afford to replace it much easier.

Technorati Tags: ,

arduino/wiring
circuits

Permalink