Please Need Help to combine two codes

HEllo eveyone, i am still a newbie in arduino programming, and i need your help. I m trying to merge two codes together, IDLE MODE CODE_FSR interrupt, and FingerScanner&Step motorCODE. My general idea for this code is, while holding a FSR sensor, the arduino will be awake , and then a finger will be scan with fingerprint scanner.If the finger is correspond with the finger image stored in the data sheet, it will move the stepmotor backward and continue waiting until FSR is release, But immediately the FSR sensor is release, the stepmotor will move back to its inital state and then arduino system will go back to idle mode to save battery. PLEASE PLEASE NEED YOUR HELP.

FYI....When my Arduino Uno is gone to IDLE mode for power save, i m using FSR sensor at pin 2 as means of interruping to wakeup the system.

FIRST CODE IS FOR SAVE POWER_IDLE MODE_CODE_FSR interrupt

#include <avr/interrupt.h>
#include <avr/power.h>
#include <avr/sleep.h>
#include <avr/io.h>
//
void setup(void)
{
DDRD &= B00000011; // set Arduino pins 2 to 7 as inputs, leaves 0 & 1 (RX & TX) as is
DDRB = B00000000; // set pins 8 to 13 as inputs
PORTD |= B11111100; // enable pullups on pins 2 to 7
PORTB |= B11111111; // enable pullups on pins 8 to 13
pinMode(13,OUTPUT); // set pin 13 as an output so we can use LED to monitor
pinMode(11,OUTPUT);
digitalWrite(13,HIGH); // turn pin 13 LED on
digitalWrite(11,HIGH);
}
//
void loop(void)
{
// Stay awake for 1 second, then sleep.
// LED turns off when sleeping, then back on upon wake.
delay(100);
sleepNow();
}
//
void sleepNow(void)
{
  while(digitalRead(2)==LOW);
    /* Now is the time to set the sleep mode. In the Atmega8 datasheet
     * http://www.atmel.com/dyn/resources/prod_documents/doc2486.pdf on page 35
     * there is a list of sleep modes which explains which clocks and
     * wake up sources are available in which sleep modus.
     *
     * In the avr/sleep.h file, the call names of these sleep modus are to be found:
     *
     * The 5 different modes are:
     *     SLEEP_MODE_IDLE         -the least power savings
     *     SLEEP_MODE_ADC
     *     SLEEP_MODE_PWR_SAVE
     *     SLEEP_MODE_STANDBY
     *     SLEEP_MODE_PWR_DOWN     -the most power savings
     *
     *  the power reduction management <avr/power.h>  is described in
     *  http://www.nongnu.org/avr-libc/user-manual/group__avr__power.html
     */
// Set pin 2 as interrupt and attach handler:
attachInterrupt(0, pinInterrupt, LOW);
delay(100);
//
// Choose our preferred sleep mode:
set_sleep_mode(SLEEP_MODE_IDLE);
//
// Set sleep enable (SE) bit:
sleep_enable();
  power_adc_disable();
  power_spi_disable();
  power_timer0_disable();
  power_timer1_disable();
  power_timer2_disable();
  power_twi_disable();
//
// Put the device to sleep:
digitalWrite(13,LOW); // turn LED off to indicate sleep
digitalWrite(11,HIGH);
sleep_mode();
//
// Upon waking up, sketch continues from this point.
sleep_disable();
digitalWrite(13,HIGH); // turn LED on to indicate awake
digitalWrite(11,LOW);
power_all_enable();

while(digitalRead(2)==LOW);

}
//
void pinInterrupt(void)
{
sleep_disable();
detachInterrupt(0);
}

The SECOND CODE is for FINGERPRINT SCANNER&STEPMOTOR

#include <Stepper.h>
#include <Adafruit_Fingerprint.h>
#if ARDUINO >= 100
#include <SoftwareSerial.h>
#else
#include <NewSoftSerial.h>
#endif

const int stepsPerRevolution = 200;  // change this to fit the number of steps per revolution
                                     // for your motor
boolean lock_state;
// initialize the stepper library on pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 8,9,10,11);          

int getFingerprintIDez();
void lock_motor();

// pin #2 is IN from sensor (GREEN wire)
// pin #3 is OUT from arduino  (WHITE wire)
#if ARDUINO >= 100
SoftwareSerial mySerial(2, 3);
#else
NewSoftSerial mySerial(2, 3);
#endif

Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);

void setup()
{
  lock_state = HIGH;
    // set the speed at 60 rpm:
  myStepper.setSpeed(60);
  // initialize the serial port:
  //Serial.begin(9600);
 
 
  Serial.begin(9600);
  Serial.println("fingertest");

  // set the data rate for the sensor serial port
  finger.begin(57600);
 
  if (finger.verifyPassword()) {
    Serial.println("Found fingerprint sensor!");
  } else {
    Serial.println("Did not find fingerprint sensor :(");
    while (1);
  }
  Serial.println("Waiting for valid finger...");
}

void loop()                     // run over and over again
{
  getFingerprintIDez();

 
//    // step one revolution  in one direction:
//   Serial.println("clockwise");
//  myStepper.step(stepsPerRevolution);
//  delay(500);
//
//   // step one revolution in the other direction:
//  Serial.println("counterclockwise");
//  myStepper.step(-stepsPerRevolution);
//  delay(500);
}

uint8_t getFingerprintID() {
  uint8_t p = finger.getImage();
  switch (p) {
    case FINGERPRINT_OK:
      Serial.println("Image taken");
      break;
    case FINGERPRINT_NOFINGER:
      Serial.println("No finger detected");
      return p;
    case FINGERPRINT_PACKETRECIEVEERR:
      Serial.println("Communication error");
      return p;
    case FINGERPRINT_IMAGEFAIL:
      Serial.println("Imaging error");
      return p;
    default:
      Serial.println("Unknown error");
      return p;
  }

  // OK success!

  p = finger.image2Tz();
  switch (p) {
    case FINGERPRINT_OK:
      Serial.println("Image converted");
      break;
    case FINGERPRINT_IMAGEMESS:
      Serial.println("Image too messy");
      return p;
    case FINGERPRINT_PACKETRECIEVEERR:
      Serial.println("Communication error");
      return p;
    case FINGERPRINT_FEATUREFAIL:
      Serial.println("Could not find fingerprint features");
      return p;
    case FINGERPRINT_INVALIDIMAGE:
      Serial.println("Could not find fingerprint features");
      return p;
    default:
      Serial.println("Unknown error");
      return p;
  }
 
  // OK converted!
  p = finger.fingerFastSearch();
  if (p == FINGERPRINT_OK) {
 

  
    Serial.println("Found a print match!");
  } else if (p == FINGERPRINT_PACKETRECIEVEERR) {
    Serial.println("Communication error");
    return p;
  } else if (p == FINGERPRINT_NOTFOUND) {
  

  
    Serial.println("Did not find a match");
    return p;
  } else {
    Serial.println("Unknown error");
    return p;
  }  
 
  // found a match!
  Serial.print("Found ID #"); Serial.print(finger.fingerID);
  Serial.print(" with confidence of "); Serial.println(finger.confidence);
}

// returns -1 if failed, otherwise returns ID #
int getFingerprintIDez() {
  uint8_t p = finger.getImage();
  if (p != FINGERPRINT_OK)  {
    lock_motor();
    return -1;
  }
  p = finger.image2Tz();
  if (p != FINGERPRINT_OK) {
    lock_motor();
    return -1;
  }

  p = finger.fingerFastSearch();
  if (p != FINGERPRINT_OK)  {
    lock_motor();
    return -1;
  }
 
  // found a match!

  Serial.print("Found ID #"); Serial.print(finger.fingerID);
  Serial.print(" with confidence of "); Serial.println(finger.confidence);
  if (lock_state == HIGH){
      //This is for the motor
  Serial.println("clockwise");
  myStepper.step(stepsPerRevolution);
  delay(500);
  lock_state = LOW;
  }
  return finger.fingerID;

}

void lock_motor(){
  if (lock_state == LOW){
    // Is for the motor step one revolution in the other direction:
  Serial.println("counterclockwise");
  myStepper.step(-stepsPerRevolution);
  delay(500);
  lock_state = HIGH;
  }
}

How are you powering the stepper motor? Those thing require a LOT of current. No dinky battery is going to power a stepper motor for any useful period of time.

PaulS:
How are you powering the stepper motor? Those thing require a LOT of current. No dinky battery is going to power a stepper motor for any useful period of time.

Thanks for your quick reply. Yes i am going to use 9V battery for stepper motor, and it is really a small stepper motor....

9V battery

Do you mean a regular store bought 9V? If so, dont bother, that battery will last you maybe 20 - 30 minutes of continious use, maybe. Unless you plan on getting 4 or 5 of them and putting them in parallel. Get a 9V rechargeable battery pack, like the ones used in Hobby RC cars. Those have a LOT of current, and can be reused.
Time wise, depends on the battery's mAh's.

HazardsMind:

9V battery

Do you mean a regular store bought 9V? If so, dont bother, that battery will last you maybe 20 - 30 minutes of continious use, maybe. Unless you plan on getting 4 or 5 of them and putting them in parallel. Get a 9V rechargeable battery pack, like the ones used in Hobby RC cars. Those have a LOT of current, and can be reused.
Time wise, depends on the battery's mAh's.

thanks for your help

Please i still need help to combine my two codes...thanks

It should just a simple drag and drop, but you have both codes using pins 11 and 2, so those will have to be changed. Another thing to watch out for is delays. The first one has two active delays but they are only 200 ms, which is not bad, but the second code also has two active delays that add up to 1 second, that might be bad. I dont know if time is an issue for you, but in total you have 1.2 seconds of delay. That 1.2 seconds it what it will take until the code is looped again.

HazardsMind:
It should just a simple drag and drop, but you have both codes using pins 11 and 2, so those will have to be changed. Another thing to watch out for is delays. The first one has two active delays but they are only 200 ms, which is not bad, but the second code also has two active delays that add up to 1 second, that might be bad. I dont know if time is an issue for you, but in total you have 1.2 seconds of delay. That 1.2 seconds it what it will take until the code is looped again.

Thanks for your help, please can you help me put them together. I do not mind if you assign the pins 11 and 2 to different pins number so they would not interfere with other, but it would be good if pin 2 still be the interrupt pin for wakeup (FSR).For the time, it matters a lot, because the whole idea for the system work faster, which ever time you think will be the best, i m willing to work with it...please help me.

Try to do it on your own first, that way you get an idea of what is happening with the codes. Try to combine them then, come back and post the combined code along with any and all errors. Now if you have no idea of even where to start and are willing to pay someone to do it for you, then check out the Gigs and Collaboration page.

http://arduino.cc/forum/index.php/board,26.0.html

I combined these codes but it is not working for me..Please help me look into this code.

#include <Stepper.h>
#include <Adafruit_Fingerprint.h>
#if ARDUINO >= 100
#include <SoftwareSerial.h>
#else
#include <NewSoftSerial.h>
#endif
#include <avr/interrupt.h>
#include <avr/power.h>
#include <avr/sleep.h>
#include <avr/io.h>
//
const int stepsPerRevolution = 200;  // change this to fit the number of steps per revolution
                                     // for your motor
boolean lock_state;
// initialize the stepper library on pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 8,9,10,11);          

int getFingerprintIDez();
void lock_motor();

// pin #2 is IN from sensor (GREEN wire)
// pin #3 is OUT from arduino  (WHITE wire)
#if ARDUINO >= 100
SoftwareSerial mySerial(2, 3);
#else
NewSoftSerial mySerial(2, 3);
#endif

Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);

//bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
void setup()
{

DDRD &= B00000011; // set Arduino pins 2 to 7 as inputs, leaves 0 & 1 (RX & TX) as is
DDRB = B00000000; // set pins 8 to 13 as inputs
PORTD |= B11111100; // enable pullups on pins 2 to 7
PORTB |= B11111111; // enable pullups on pins 8 to 13
pinMode(13,OUTPUT); // set pin 13 as an output so we can use LED to monitor
pinMode(11,OUTPUT);
digitalWrite(13,HIGH); // turn pin 13 LED on
digitalWrite(11,HIGH);

  lock_state = HIGH;
    // set the speed at 60 rpm:
  myStepper.setSpeed(60);
  // initialize the serial port:
  //Serial.begin(9600);
 
 
  Serial.begin(9600);
  Serial.println("fingertest");

  // set the data rate for the sensor serial port
  finger.begin(57600);
 
  if (finger.verifyPassword()) {
    Serial.println("Found fingerprint sensor!");
  } else {
    Serial.println("Did not find fingerprint sensor :(");
    while (1);
  }
  Serial.println("Waiting for valid finger...");
}

//bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
void loop()                     // run over and over again
{
// Stay awake for 1 second, then sleep.
// LED turns off when sleeping, then back on upon wake.
delay(100);
sleepNow();

  getFingerprintIDez();

}
//bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
void sleepNow(void)
{
  while(digitalRead(2)==LOW);
  
// Set pin 2 as interrupt and attach handler:
attachInterrupt(0, pinInterrupt, LOW);
delay(100);
//
// Choose our preferred sleep mode:
set_sleep_mode(SLEEP_MODE_IDLE);
//
// Set sleep enable (SE) bit:
sleep_enable();
  power_adc_disable();
  power_spi_disable();
  power_timer0_disable();
  power_timer1_disable();
  power_timer2_disable();
  power_twi_disable();

// Put the device to sleep:
digitalWrite(13,LOW); // turn LED off to indicate sleep
digitalWrite(11,HIGH);
sleep_mode();
//
// Upon waking up, sketch continues from this point.
sleep_disable();
digitalWrite(13,HIGH); // turn LED on to indicate awake
digitalWrite(11,LOW);
power_all_enable();

while(digitalRead(2)==LOW);

}
//bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb

uint8_t getFingerprintID() {
  uint8_t p = finger.getImage();
  switch (p) {
    case FINGERPRINT_OK:
      Serial.println("Image taken");
      break;
    case FINGERPRINT_NOFINGER:
      Serial.println("No finger detected");
      return p;
    case FINGERPRINT_PACKETRECIEVEERR:
      Serial.println("Communication error");
      return p;
    case FINGERPRINT_IMAGEFAIL:
      Serial.println("Imaging error");
      return p;
    default:
      Serial.println("Unknown error");
      return p;
  }

  // OK success!

  p = finger.image2Tz();
  switch (p) {
    case FINGERPRINT_OK:
      Serial.println("Image converted");
      break;
    case FINGERPRINT_IMAGEMESS:
      Serial.println("Image too messy");
      return p;
    case FINGERPRINT_PACKETRECIEVEERR:
      Serial.println("Communication error");
      return p;
    case FINGERPRINT_FEATUREFAIL:
      Serial.println("Could not find fingerprint features");
      return p;
    case FINGERPRINT_INVALIDIMAGE:
      Serial.println("Could not find fingerprint features");
      return p;
    default:
      Serial.println("Unknown error");
      return p;
  }
 
  // OK converted!
  p = finger.fingerFastSearch();
  if (p == FINGERPRINT_OK) {
 

  
    Serial.println("Found a print match!");
  } else if (p == FINGERPRINT_PACKETRECIEVEERR) {
    Serial.println("Communication error");
    return p;
  } else if (p == FINGERPRINT_NOTFOUND) {
  

  
    Serial.println("Did not find a match");
    return p;
  } else {
    Serial.println("Unknown error");
    return p;
  }  
 
  // found a match!
  Serial.print("Found ID #"); Serial.print(finger.fingerID);
  Serial.print(" with confidence of "); Serial.println(finger.confidence);
}

// returns -1 if failed, otherwise returns ID #
int getFingerprintIDez() {
  uint8_t p = finger.getImage();
  if (p != FINGERPRINT_OK)  {
    lock_motor();
    return -1;
  }
  p = finger.image2Tz();
  if (p != FINGERPRINT_OK) {
    lock_motor();
    return -1;
  }

  p = finger.fingerFastSearch();
  if (p != FINGERPRINT_OK)  {
    lock_motor();
    return -1;
  }
 
  // found a match!

  Serial.print("Found ID #"); Serial.print(finger.fingerID);
  Serial.print(" with confidence of "); Serial.println(finger.confidence);
  if (lock_state == HIGH){
      //This is for the motor
  Serial.println("clockwise");
  myStepper.step(stepsPerRevolution);
  delay(500);
  lock_state = LOW;
  }
  return finger.fingerID;

}

void lock_motor(){
  if (lock_state == LOW){
    // Is for the motor step one revolution in the other direction:
  Serial.println("counterclockwise");
  myStepper.step(-stepsPerRevolution);
  delay(500);
  lock_state = HIGH;
  }
}



//bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
void pinInterrupt(void)
{
sleep_disable();
detachInterrupt(0);
}

I merged two codes but not sure i m doing it correct. Please can someone looking into my program and see i m doing it correct because i am not good in programming...thanks

#include <Stepper.h>
#include <Adafruit_Fingerprint.h>
#if ARDUINO >= 100
#include <SoftwareSerial.h>
#else
#include <NewSoftSerial.h>
#endif
#include <avr/interrupt.h>
#include <avr/power.h>
#include <avr/sleep.h>
#include <avr/io.h>
//
const int stepsPerRevolution = 200;  // change this to fit the number of steps per revolution
                                     // for your motor
boolean lock_state;
// initialize the stepper library on pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 8,9,10,11);          

int getFingerprintIDez();
void lock_motor();

// pin #4 is IN from sensor (GREEN wire)
// pin #3 is OUT from arduino  (WHITE wire)
#if ARDUINO >= 100
SoftwareSerial mySerial(4, 3);
#else
NewSoftSerial mySerial(4, 3);
#endif

Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);

//bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
void setup()
{

DDRD &= B00000011; // set Arduino pins 2 to 7 as inputs, leaves 0 & 1 (RX & TX) as is
DDRB = B00000000; // set pins 8 to 13 as inputs
PORTD |= B11111100; // enable pullups on pins 2 to 7
PORTB |= B11111111; // enable pullups on pins 8 to 13
pinMode(13,OUTPUT); // set pin 13 as an output so we can use LED to monitor
pinMode(11,OUTPUT);
digitalWrite(13,HIGH); // turn pin 13 LED on
digitalWrite(11,HIGH);

  lock_state = HIGH;
    // set the speed at 60 rpm:
  myStepper.setSpeed(60);
  // initialize the serial port:
  //Serial.begin(9600);
 
 
  Serial.begin(9600);
  Serial.println("fingertest");

  // set the data rate for the sensor serial port
  finger.begin(57600);
 
  if (finger.verifyPassword()) {
    Serial.println("Found fingerprint sensor!");
  } else {
    Serial.println("Did not find fingerprint sensor :(");
    while (1);
  }
  Serial.println("Waiting for valid finger...");
}

//bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
void loop()                     // run over and over again
{
// Stay awake for 1 second, then sleep.
// LED turns off when sleeping, then back on upon wake.
delay(100);
sleepNow();

  getFingerprintIDez();

}
//bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
void sleepNow(void)
{
  while(digitalRead(2)==LOW);
  
// Set pin 2 as interrupt and attach handler:
attachInterrupt(0, pinInterrupt, LOW);
delay(100);
//
// Choose our preferred sleep mode:
set_sleep_mode(SLEEP_MODE_IDLE);
//
// Set sleep enable (SE) bit:
sleep_enable();
  power_adc_disable();
  power_spi_disable();
  power_timer0_disable();
  power_timer1_disable();
  power_timer2_disable();
  power_twi_disable();

// Put the device to sleep:
digitalWrite(13,LOW); // turn LED off to indicate sleep
digitalWrite(6,HIGH);
sleep_mode();
//
// Upon waking up, sketch continues from this point.
sleep_disable();
digitalWrite(13,HIGH); // turn LED on to indicate awake
digitalWrite(6,LOW);
power_all_enable();

while(digitalRead(2)==LOW);

}
//bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb

uint8_t getFingerprintID() {
  uint8_t p = finger.getImage();
  switch (p) {
    case FINGERPRINT_OK:
      Serial.println("Image taken");
      break;
    case FINGERPRINT_NOFINGER:
      Serial.println("No finger detected");
      return p;
    case FINGERPRINT_PACKETRECIEVEERR:
      Serial.println("Communication error");
      return p;
    case FINGERPRINT_IMAGEFAIL:
      Serial.println("Imaging error");
      return p;
    default:
      Serial.println("Unknown error");
      return p;
  }

  // OK success!

  p = finger.image2Tz();
  switch (p) {
    case FINGERPRINT_OK:
      Serial.println("Image converted");
      break;
    case FINGERPRINT_IMAGEMESS:
      Serial.println("Image too messy");
      return p;
    case FINGERPRINT_PACKETRECIEVEERR:
      Serial.println("Communication error");
      return p;
    case FINGERPRINT_FEATUREFAIL:
      Serial.println("Could not find fingerprint features");
      return p;
    case FINGERPRINT_INVALIDIMAGE:
      Serial.println("Could not find fingerprint features");
      return p;
    default:
      Serial.println("Unknown error");
      return p;
  }
 
  // OK converted!
  p = finger.fingerFastSearch();
  if (p == FINGERPRINT_OK) {
 

  
    Serial.println("Found a print match!");
  } else if (p == FINGERPRINT_PACKETRECIEVEERR) {
    Serial.println("Communication error");
    return p;
  } else if (p == FINGERPRINT_NOTFOUND) {
  

  
    Serial.println("Did not find a match");
    return p;
  } else {
    Serial.println("Unknown error");
    return p;
  }  
 
  // found a match!
  Serial.print("Found ID #"); Serial.print(finger.fingerID);
  Serial.print(" with confidence of "); Serial.println(finger.confidence);
}

// returns -1 if failed, otherwise returns ID #
int getFingerprintIDez() {
  uint8_t p = finger.getImage();
  if (p != FINGERPRINT_OK)  {
    lock_motor();
    return -1;
  }
  p = finger.image2Tz();
  if (p != FINGERPRINT_OK) {
    lock_motor();
    return -1;
  }

  p = finger.fingerFastSearch();
  if (p != FINGERPRINT_OK)  {
    lock_motor();
    return -1;
  }
 
  // found a match!

  Serial.print("Found ID #"); Serial.print(finger.fingerID);
  Serial.print(" with confidence of "); Serial.println(finger.confidence);
  if (lock_state == HIGH){
      //This is for the motor
  Serial.println("clockwise");
  myStepper.step(stepsPerRevolution);
  delay(500);
  lock_state = LOW;
  }
  return finger.fingerID;

}

void lock_motor(){
  if (lock_state == LOW){
    // Is for the motor step one revolution in the other direction:
  Serial.println("counterclockwise");
  myStepper.step(-stepsPerRevolution);
  delay(500);
  lock_state = HIGH;
  }
}



//bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
void pinInterrupt(void)
{
sleep_disable();
detachInterrupt(0);
}

What are you getting as opposed to what your not getting?

From what I see, your getting some confliction here.
DDRB = B00000000; // set pins 8 to 13 as inputs
pinMode(13,OUTPUT);
pinMode(11,OUTPUT);

I can't look at all of if right now, myself, but just skimming through it, there are a few mistakes.

You know both codes work indepently, so try some debugging with the serial monitor.

Post any and all errors.

HazardsMind:
What are you getting as opposed to what your not getting?

From what I see, your getting some confliction here.
DDRB = B00000000; // set pins 8 to 13 as inputs
pinMode(13,OUTPUT);
pinMode(11,OUTPUT);

I can't look at all of if right now, myself, but just skimming through it, there are a few mistakes.

You know both codes work indepently, so try some debugging with the serial monitor.

Post any and all errors.

I tried to combine it, there was a problem saying UNDIFINED REFRENCE TO 'SETUP'

#include <avr/interrupt.h>
#include <avr/power.h>
#include <avr/sleep.h>
#include <avr/io.h>

#include <VirtualWire.h>

#include <Stepper.h>
#include <Adafruit_Fingerprint.h>
#if ARDUINO >= 100
 #include <SoftwareSerial.h>
#else
 #include <NewSoftSerial.h>
#endif
const int stepsPerRevolution = 200;  // change this to fit the number of steps per revolution
                                     // for your motor
boolean lock_state;
// initialize the stepper library on pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 8,9,10,11);            

int getFingerprintIDez();
void lock_motor();

// pin #6 is IN from sensor (GREEN wire)
// pin #7 is OUT from arduino  (WHITE wire)
#if ARDUINO >= 100
SoftwareSerial mySerial(6, 7);
#else
NewSoftSerial mySerial(6, 7);
#endif

Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);

void sleepsetup(void)
{
DDRD &= B00000011; // set Arduino pins 2 to 7 as inputs, leaves 0 & 1 (RX & TX) as is
DDRB = B00000000; // set pins 8 to 13 as inputs
PORTD |= B11111100; // enable pullups on pins 2 to 7
PORTB |= B11111111; // enable pullups on pins 8 to 13
pinMode(5,OUTPUT); // set pin 13 as an output so we can use LED to monitor
pinMode(12,OUTPUT);
digitalWrite(5,HIGH); // turn pin 13 LED on
digitalWrite(12,HIGH);

}

void fingersetup()  
{
  lock_state = HIGH;
    // set the speed at 60 rpm:
  myStepper.setSpeed(60);
  // initialize the serial port:
  //Serial.begin(9600);
  
  
  Serial.begin(9600);
  Serial.println("fingertest");

  // set the data rate for the sensor serial port
  finger.begin(57600);
  
  if (finger.verifyPassword()) {
    Serial.println("Found fingerprint sensor!");
  } else {
    Serial.println("Did not find fingerprint sensor :(");
    while (1);
  }
  Serial.println("Waiting for valid finger...");
}


void Recieversetup()
{
    Serial.begin(9600);	// Debugging only
    Serial.println("RECEIVER");

    // Initialise the IO and ISR
    vw_set_ptt_inverted(true); // Required for DR3100
    vw_setup(2000);	 // Bits per sec
    vw_set_rx_pin(4);
    vw_rx_start();      
    pinMode(13, OUTPUT);
}

void loop(void)
{
  delay(100);               //execute loop 10 times/second
  if (HIGH == digitalRead(2))      // if the FSR is not pressed
  {
    sleepNow();               // then go to sleep.  Stays asleep until FSR is pressed.
  }
delay(100);
   int msg_status = vw_have_message();
   uint8_t buf[VW_MAX_MESSAGE_LEN];
   uint8_t buflen = VW_MAX_MESSAGE_LEN;
   
   if (vw_get_message(buf, &buflen)); // Non-blocking [to reset the vw_rx_done flag]
   if(msg_status==1)
    {
        Serial.println("Something");
        getFingerprintIDez();
        digitalWrite(13, HIGH); 
        delay(100);

     }
   else
   {
     Serial.println("Nothing");
     delay(100);
   }
   digitalWrite(13, LOW);
}

void fingerloop()                     // run over and over again
{
  getFingerprintIDez();
}

uint8_t getFingerprintID() {
  uint8_t p = finger.getImage();
  switch (p) {
    case FINGERPRINT_OK:
      Serial.println("Image taken");
      break;
    case FINGERPRINT_NOFINGER:
      Serial.println("No finger detected");
      return p;
    case FINGERPRINT_PACKETRECIEVEERR:
      Serial.println("Communication error");
      return p;
    case FINGERPRINT_IMAGEFAIL:
      Serial.println("Imaging error");
      return p;
    default:
      Serial.println("Unknown error");
      return p;
  }

  // OK success!

  p = finger.image2Tz();
  switch (p) {
    case FINGERPRINT_OK:
      Serial.println("Image converted");
      break;
    case FINGERPRINT_IMAGEMESS:
      Serial.println("Image too messy");
      return p;
    case FINGERPRINT_PACKETRECIEVEERR:
      Serial.println("Communication error");
      return p;
    case FINGERPRINT_FEATUREFAIL:
      Serial.println("Could not find fingerprint features");
      return p;
    case FINGERPRINT_INVALIDIMAGE:
      Serial.println("Could not find fingerprint features");
      return p;
    default:
      Serial.println("Unknown error");
      return p;
  }
  
  // OK converted!
  p = finger.fingerFastSearch();
  if (p == FINGERPRINT_OK) {
  

   
    Serial.println("Found a print match!");
  } else if (p == FINGERPRINT_PACKETRECIEVEERR) {
    Serial.println("Communication error");
    return p;
  } else if (p == FINGERPRINT_NOTFOUND) {
    

   
    Serial.println("Did not find a match");
    return p;
  } else {
    Serial.println("Unknown error");
    return p;
  }   
  
  // found a match!
  Serial.print("Found ID #"); Serial.print(finger.fingerID); 
  Serial.print(" with confidence of "); Serial.println(finger.confidence); 
}

// returns -1 if failed, otherwise returns ID #
int getFingerprintIDez() {
  uint8_t p = finger.getImage();
  if (p != FINGERPRINT_OK)  {
    lock_motor();
    return -1;
  }
  p = finger.image2Tz();
  if (p != FINGERPRINT_OK) {
    lock_motor();
    return -1;
  }

  p = finger.fingerFastSearch();
  if (p != FINGERPRINT_OK)  {
    lock_motor();
    return -1;
  }
  
  // found a match!

  Serial.print("Found ID #"); Serial.print(finger.fingerID); 
  Serial.print(" with confidence of "); Serial.println(finger.confidence);
  if (lock_state == HIGH){
      //This is for the motor  
  Serial.println("clockwise");
  myStepper.step(stepsPerRevolution);
  delay(500);
  lock_state = LOW;
  }
  return finger.fingerID; 

}

void lock_motor(){
  if (lock_state == LOW){
    // Is for the motor step one revolution in the other direction:
  Serial.println("counterclockwise");
  myStepper.step(-stepsPerRevolution);
  delay(500); 
  lock_state = HIGH;
  }
}

void sleeploop(void)
{
  delay(100);               //execute loop 10 times/second
  if (HIGH == digitalRead(2))      // if the FSR is not pressed
  {
    sleepNow();               // then go to sleep.  Stays asleep until FSR is pressed.
  }
}
void sleepNow(void) {
  sleep_enable();
  attachInterrupt(0, pinInterrupt, LOW);
  delay(100);
  set_sleep_mode(SLEEP_MODE_IDLE);
  power_adc_disable();
  power_spi_disable();
  power_timer0_disable();
  power_timer1_disable();
  power_timer2_disable();
  power_twi_disable();

  digitalWrite(5,LOW); // turn LED off to indicate sleep
  sleep_mode();
  digitalWrite(5,HIGH); // turn LED on to indicate awake
power_all_enable();

}

void pinInterrupt(void) {
  sleep_disable();
  detachInterrupt(0);
}

You don't have a setup() function.

HazardsMind:
You don't have a setup() function.

I thought if i rename my setup() fuctions, that will prevent it from interfering with other functions... Please can you take a look at my code..

You MUST have a setup() function, that is what the error message is telling you. Copy the statements from both setup() functions into setup() in the new combined code. Look out for conflicts such as the same pin being used for different purposes in each original program.

If you are still stuck after combining the 2 setup() functions post your whole code here again. There is no point looking at your code as it is now because there is no setup() function.

Copy the statements from both setup() functions into setup() in the new combined code.

Or, better yet, call the two setupxxxx() functions that you do have from the new setup() function.

Good idea. although I think it would be easier to spot conflicts, especially in the use of pins, if the setup was in one function rather than two.

Good idea. although I think it would be easier to spot conflicts, especially in the use of pins, if the setup was in one function rather than two.

Agreed. Though, the code should probably be moved, then, not copied.