This was a personal challenge, I wanted to design something similar to the Android Unlock Pattern in less than 30 minutes.
Basically, you set the points which you must go to (e.g. go to point 1,1 then point 50,50). Thankfully, because it would be really hard to hit exactly the point, we can set up boundaries (point 1 is between 1,1 and 10,10). This makes it much easier to 'hit' the point. Additionally we have to make sure that you've been to the previous point so you can't to the pattern the wrong way around.

## Step 1: What You'll Need.

You want to have an Arduino, an LCD (here it's a nokia 3310/5510 display) and a nintendo DS Touchscreen. Buy the breakout board for that, it's really difficult to wire it otherwise. You'll also want some some wires.

## Step 2: How It Works.

The aim was to make this in less than half an hour. At the moment, it is a very ugly piece of code. It is also not very secure. I have yet to implement a way to prevent people from guessing the code by touching everywhere on the display. There is currently a timer that sets of when you touch the first point and re-initialises the sketch if you aren't fast enough but you really, really shouldn't use this for something you want to secure properly. If I have time, I'll try and make a library for it but then again, with exams during the whole year, time is an issue.

Please don't use this for secure stuff. It's for fun.
But then again, the real thing isn't that much too:

## Step 3: Wiring

*DS touchscreen to Analog 1,2,3,4

*LCD to Digital 7,6,5,4,3

if you don't know how to connect these, google around.
There is no point in me explaining something that has already been explained a thousand time.

## Step 4: Code

This is the code. Notice at the end how I define points and how the booleans are 'trued' to make sure everything is good.

#include "PCD8544.h"

int y1 = A0;
int x2 = A1;
int y2 = A2;
int x1 = A3;

boolean point1;
boolean point2;
boolean point3;
boolean point4;
boolean point5;

boolean unlocked;

int i=0;

// pin 7 - Serial clock out (SCLK)
// pin 6 - Serial data out (DIN)
// pin 5 - Data/Command select (D/C)
// pin 4 - LCD chip select (CS)
// pin 3 - LCD reset (RST)
PCD8544 nokia = PCD8544(7, 6, 5, 4, 3);

// a bitmap of a 16x16 fruit icon
static unsigned char __attribute__ ((progmem)) logo16_glcd_bmp[]={
0x30, 0xf0, 0xf0, 0xf0, 0xf0, 0x30, 0xf8, 0xbe, 0x9f, 0xff, 0xf8, 0xc0, 0xc0, 0xc0, 0x80, 0x00,
0x20, 0x3c, 0x3f, 0x3f, 0x1f, 0x19, 0x1f, 0x7b, 0xfb, 0xfe, 0xfe, 0x07, 0x07, 0x07, 0x03, 0x00, };
#define LOGO16_GLCD_HEIGHT 16
#define LOGO16_GLCD_WIDTH 16

void setup(void) {

pinMode(11, OUTPUT);
digitalWrite(11, HIGH);

nokia.init();
// you can change the contrast around to adapt the display
// for the best viewing!
nokia.setContrast(50);
// turn all the pixels on (a handy test)
nokia.command(PCD8544_DISPLAYCONTROL | PCD8544_DISPLAYALLON);
delay(500);
// back to normal
nokia.command(PCD8544_DISPLAYCONTROL | PCD8544_DISPLAYNORMAL);

}

pinMode(y1, INPUT);
pinMode(x2, OUTPUT);
pinMode(y2, INPUT);
pinMode(x1, OUTPUT);

digitalWrite(x2, LOW);
digitalWrite(x1, HIGH);

delay(5); //pause to allow lines to power up

}

pinMode(y1, OUTPUT);
pinMode(x2, INPUT);
pinMode(y2, OUTPUT);
pinMode(x1, INPUT);

digitalWrite(y1, LOW);
digitalWrite(y2, HIGH);

delay(5); //pause to allow lines to power up

}

void loop (void) {

int x = readX();
int y = readY();

nokia.setCursor(0, 0);
nokia.print("Draw unlock");
nokia.setCursor(0, 10);
nokia.print("Pattern");
nokia.display();

if(x <= 970 & x >= 870 & y <= 250 & y >= 150 ){
point1 = true;
nokia.setCursor(0,25);
nokia.print("Goto point 2");

}

if(point1 == true){
i++;
nokia.setCursor(0,40);
nokia.print(i);
}

if(point1 == true & x <= 200 & x >= 90 & y <= 930 & y >= 830){
point2 = true;
nokia.setCursor(0,25);
nokia.print("Goto point 3");
}

if(point2 == true & x <= 165 & x >= 90 & y <= 250 & y >= 120){
point3 = true;
nokia.setCursor(0,25);
nokia.print("Goto point 4");
}

if(point3 == true & x <= 999 & x >= 865 & y <= 950 & y >= 800){
point4 = true;
nokia.setCursor(0,25);
nokia.print("Goto point 5");
}

if(point4 == true & x <= 970 & x >= 870 & y <= 250 & y >= 150){
point5 = true;
unlocked = true;
point1 = false;
nokia.clear();
nokia.setCursor(0,25);
nokia.print("Unlocked ");

}

if(i >= 150){
point1 = false;
point2 = false;
point3 = false;
point4 = false;
point5 = false;

nokia.setCursor(0,25);
nokia.print("Too slow! ");
}

}
I have created a pattern lock for Arduino on lines of Android pattern lock using Arduino and 3.2&quot; touch screen TFT. Checkout my blog post: <a href="http://www.ravivarmapm.com/blog/2012/07/26/arduino-pattern-lock-unlock-android/" rel="nofollow">http://www.ravivarmapm.com/blog/2012/07/26/arduino-pattern-lock-unlock-android/</a>.