Sparkfun Touch Shield: Programming

I am a newbie and I got myself a sparkfun Touch Shield I am trying to modify the example code on the sparkfun site: www.sparkfun.com/capsense to allow me to enter a code ex:1234 to turn a pin ex:1 on and then enter the same code and turn it off. PLEASE HELP!!!!!

I am trying to modify the example code on the sparkfun site

Then, your code is no longer what is at that site, is it?

PLEASE HELP!!!!!

WHAT DO YOU NEED HELP WITH?????? Your hearing aids?

PLEASE HELP!!!!!

WHAT DO YOU NEED HELP WITH?????? Your hearing aids?

to allow me to enter a code ex:1234 to turn a pin ex:1 on and then enter the same code and turn it off.

to allow me to enter a code ex:1234 to turn a pin ex:1 on and then enter the same code and turn it off.

OK. Your problem is on line 98. Fix that, and it will work. Or not. Where is your code? What happens when you run it? How does that differ from what you want?

Here is my code

// include the atmel I2C libs
#include "mpr121.h"
#include "i2c.h"


// Match key inputs with electrode numbers
#define ONE 8
#define TWO 5
#define THREE 2
#define FOUR 7
#define FIVE 4
#define SIX 1
#define SEVEN 6
#define EIGHT 3
#define NINE 0

//extras (not used)
#define ELE9 9
#define ELE10 10
#define ELE11 11

//interupt pin
int irqpin = 2;  // D2

void setup()
{
  //make sure the interrupt pin is an input and pulled high
  pinMode(6, OUTPUT);
  pinMode(irqpin, INPUT);
  digitalWrite(irqpin, HIGH);
  
  //configure serial out
  Serial.begin(9600);
  
  //output on ADC4 (PC4, SDA)
  DDRC |= 0b00010011;
  // Pull-ups on I2C Bus
  PORTC = 0b00110000; 
  // initalize I2C bus. Wiring lib not used. 
  i2cInit();
  
  delay(100);
  // initialize mpr121
  mpr121QuickConfig();
  
  // prints 'Ready...' when you can start hitting numbers
  Serial.println("Ready...");
}

void loop()
{
  uint16_t touchstatus;
  
  touchstatus = mpr121Read(0x01) << 8;
  touchstatus |= mpr121Read(0x00);
  
  if (touchstatus & (1<<ONE))
  if (touchstatus & (1<<TWO))
      digitalWrite(6, LOW);
    
  if (touchstatus & (1<<TWO))
  if (touchstatus & (1<<THREE))
      digitalWrite(6, HIGH);
}

With this you have to press the numbers at the same time

I would like to be able to press the keys with a delay in between but when I add delay(1000); the led i'm testing with won't turn on at all

Sorry uploaded the wrong code
HERE IS THE RIGHT CODE

// include the atmel I2C libs
#include "mpr121.h"
#include "i2c.h"


// Match key inputs with electrode numbers
#define ONE 8
#define TWO 5
#define THREE 2
#define FOUR 7
#define FIVE 4
#define SIX 1
#define SEVEN 6
#define EIGHT 3
#define NINE 0

//extras (not used)
#define ELE9 9
#define ELE10 10
#define ELE11 11

//interupt pin
int irqpin = 2;  // D2

void setup()
{
  //make sure the interrupt pin is an input and pulled high
  pinMode(6, OUTPUT);
  pinMode(irqpin, INPUT);
  digitalWrite(irqpin, HIGH);
  
  //configure serial out
  Serial.begin(9600);
  
  //output on ADC4 (PC4, SDA)
  DDRC |= 0b00010011;
  // Pull-ups on I2C Bus
  PORTC = 0b00110000; 
  // initalize I2C bus. Wiring lib not used. 
  i2cInit();
  
  delay(100);
  // initialize mpr121
  mpr121QuickConfig();
  
  // prints 'Ready...' when you can start hitting numbers
  Serial.println("Ready...");
}

void loop()
{
  uint16_t touchstatus;
  
  touchstatus = mpr121Read(0x01) << 8;
  touchstatus |= mpr121Read(0x00);
  
  if (touchstatus & (1<<ONE))
  if (touchstatus & (1<<TWO))
      digitalWrite(6, LOW);
    
  if (touchstatus & (1<<ONE))
  if (touchstatus & (1<<TWO))
      digitalWrite(6, HIGH);
}

The sparkfun site has a number of code snippets. One is the getNumber() function. It looks to me like that function should be part of your code.

It also looks, from that code, that

  if (touchstatus & (1<<ONE))

returns true if the square labeled 1 was touched.

Why you only test for 2 being touched if one is being touched is rather a mystery.

Read and understand the getNumber() function on the sparkfun site.

When you hold keys 1 and 2 down the led turns on until you release
The code i'm using is

// include the atmel I2C libs
#include "mpr121.h"
#include "i2c.h"


// Match key inputs with electrode numbers
#define ONE 8
#define TWO 5
#define THREE 2
#define FOUR 7
#define FIVE 4
#define SIX 1
#define SEVEN 6
#define EIGHT 3
#define NINE 0

//extras (not used)
#define ELE9 9
#define ELE10 10
#define ELE11 11

//interupt pin
int irqpin = 2;  // D2

void setup()
{
  //make sure the interrupt pin is an input and pulled high
  pinMode(6, OUTPUT);
  pinMode(irqpin, INPUT);
  digitalWrite(irqpin, HIGH);
  
  //configure serial out
  Serial.begin(9600);
  
  //output on ADC4 (PC4, SDA)
  DDRC |= 0b00010011;
  // Pull-ups on I2C Bus
  PORTC = 0b00110000; 
  // initalize I2C bus. Wiring lib not used. 
  i2cInit();
  
  delay(100);
  // initialize mpr121
  mpr121QuickConfig();
  
  // prints 'Ready...' when you can start hitting numbers
  Serial.println("Ready...");
}

void loop()
{
  uint16_t touchstatus;
  
  touchstatus = mpr121Read(0x01) << 8;
  touchstatus |= mpr121Read(0x00);
  
  if (touchstatus & (1<<ONE))
  if (touchstatus & (1<<TWO))
      digitalWrite(6, HIGH);
    
  if (touchstatus & (1<<ONE))
  if (touchstatus & (1<<TWO))
      digitalWrite(6, LOW);
}

Could you drop a link to that page I can't seem to find it

When you hold keys 1 and 2 down the led turns on until you release

OK. And, what is it you want to have happen?

Could you drop a link to that page I can't seem to find it

Its the one in your initial post. Scroll down a bit.

http://www.sparkfun.com/tutorials/288

Edit: That's strange. I clicked on the link in the first post, and it took me to a site. When I copy the URL and paste it here, it's not the same one.

It's a redirect page. And I want to be able to have a delay between pressing the numbers and the output to stay on after releasing the last button (please use example code 1234)

On any given pass through loop, you should be detecting which, if any, "key" is being pressed, if you are trying to use this as a keypad. That's the first but of code you should develop. The code that you have now that detects the simultaneous press of two "key"s is a good starting point. Put that in a function that returns an int. Get rid of the two presses bit. Make the function return a value - -1 for no key, 0 to 9 for the actual key. Look at the getNumber() function for clues.

When you have a function that can tell you which key, if any, is pressed, on any pass through loop, then you need to determine if it is the same key as last time. For this, you need two variables (global) - currKey and prevKey. The currKey variable will be valued by the call to the function you write. The prevKey variable will be set to currKey at the end of loop. Then, you can use:

if(currKey != prevKey)
{
}

to see when a change occurs.

Inside that block, you need to make sure that currKey is not no key. If it isn't, then add the key to the array or value you are recording data in. A value is easier.

int value = 0;
value *= 10;
value += currKey;

Independent of the touch screen code, you would test whether value is 1234 (or whatever "password" you choose. If so, change the LED state.

Independent of that, you apply the LED state to the LED.

In pseudo code:
void loop
currKey = getKey()
if currKey not prevKey
multiply value by 10
add currKey
prevKey = currkey

if value equal password
state = !state

digitalWrite state to led pin

I tried using this code, and it kept on giving me this error: This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.
Arduino: 1.0.6 (Windows NT (unknown)), Board: "Arduino Uno"
sketch_jul22a.ino:2:20: error: mpr121.h: No such file or directory
sketch_jul22a.ino:3:17: error: i2c.h: No such file or directory
sketch_jul22a.ino: In function 'void setup()':
sketch_jul22a:40: error: 'i2cInit' was not declared in this scope
sketch_jul22a:44: error: 'mpr121QuickConfig' was not declared in this scope
sketch_jul22a.ino: In function 'void loop()':
sketch_jul22a:54: error: 'mpr121Read' was not declared in this scope

I just copied what was posted in the most recent part of this forum. Anyone able to help?

I am quite new to Arduino and programming, so I don't know a lot of things.

I tried using this code

What code would that be?

I just copied what was posted in the most recent part of this forum.

Without bothering to download any of the libraries needed.