Writing to Mifare RFID tags

Mifare RFID tags, like other RFID tags, contain a serial number that can be read using an RFID reader, but they also have a limited amount of memory space that you can write data to, and read back from.  This can be handy if you want to do something like keep a user’s account balance or name directly on the RFID tag.

This tutorial shows a number of the functions of my sonMicroReader  library for Processing, including how to write to the memory on tags.  It uses the same circuit as the SM130 reader example. The entire sketch can be downloaded here:

sonmicro_writer_0001

Continue reading “Writing to Mifare RFID tags”

Reading Mifare RFID Tags

This tutorial explains how to read from Mifare RFID tags from your computer using a Sonmicro SM130 read/write module. The sketch below is written in Processing using my SonmicroReader library. The SM130 has a TTL serial interface that you can connect to a micocontroller, or to a personal computer through a USB-to-serial interface.  Using the latter, it’s pretty simple to send serial commands to it and receive the data back. The entire Processing sketch can be downloaded here: rfid_simple_0001.

Continue reading “Reading Mifare RFID Tags”

Sonmicro RFID Reader Library for Processing

Last year, I worked with Timo Arnall and Einar Martinussen and Jørn Knutsen on a Processing library to read and write to Mifare RFID tags using the Sonmicro SM130 read/write module.  Here it is, with a few improvements and bug fixes.

SonMicroReader.zip

To use the library, unzip it and copy the folder to your Processing libraries folder.  Then restart Processing.  There are two example sketches, a simple reader that seeks new tags, and a full read/write example.

For more details, see the datasheet for the module. Code examples will follow in this blog.

Continue reading “Sonmicro RFID Reader Library for Processing”

Clock

Here’s a quick digital clock in Processing. It also sends the time out a serial port. I use this for testing when I need for a microcontroller or other serial device to receive a string.

/*
  Clock

 Draws a digital clock in the center of the screen
 and sends the string out the serial port.

 created 7 Oct 2008
 by Tom Igoe
 */

import processing.serial.*;

Serial myPort;    // instance of the serial library

void setup() {
  // open the applet window:
  size(300, 200);
  // initialize the font for text display:
  PFont myFont = createFont(PFont.list()[0], 24);
  textFont(myFont);
  // align all text center:
  textAlign(CENTER);
  // open a serial port:
  myPort = new Serial(this, Serial.list()[0], 9600);
}

void draw(){
  // clear the screen:
  background(0);
  // make a string of hour: minute:second.  Use nf()
  // to format the numbers in two digits each:
  String theTime = nf(hour(), 2) + ":" + nf(minute(), 2) + ":"+ nf(second(), 2);
  // draw it in the middle of the screen:
  text(theTime, width/2, height/2);
  // send it out the serial port:
  myPort.write(theTime + "\n");
  // wait one second before doing it again:
  delay(1000);
}

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 “Multiple time stamp checks on a microcontroller”

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 “Using an Accelerometer to Sense Which Way Is Up”