Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- More info at my blog: asselinpaul.posterous.com
- #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);
- }
- int readX(){
- 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
- return analogRead(y1);
- }
- int readY(){
- 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
- return analogRead(x2);
- }
- 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! ");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement