Show Posts
Pages: [1] 2 3 ... 5
1  Using Arduino / Project Guidance / Re: Setting XBee AT commands as background process? on: February 12, 2013, 11:11:41 am
Quote

Thank you so much! I cannot believe I never saw that. I really need to do more research before I start programming. That is exactly what I need for my project. Now I just need to convert my GPS coordinates to Hex, but that should be simple.

Thanks again Jack.
2  Using Arduino / Project Guidance / Re: Setting XBee AT commands as background process? on: February 11, 2013, 10:02:59 pm
Hey,

Thanks for the quick replies!

Quote
Rather than delaying 1200 ms and then throwing away any response from the XBee, it would be better to read and process the response as it arrives until you have got a success or failure indication.

I agree, but for now I am just trying to get this to work for now and then add the error checking.

Quote
API mode. No waiting. Send the command, get the response within milliseconds.

I am not quite sure what you mean by APi mode.. I did a quick google search and it states that you can broadcast to all xbees? What I would like to do is only broadcast to a specific XBee then swap to send to the other one later on.  I am also trying to use point to point communication because it seems to be a lot faster in sending and I don't think there is as much data loss, though I am by far no expert with the XBees and am not quite sure if this is true.

Quote
Why do you need to reconfigure the XBee, anyway? What is it talking to at other times? Where do you switch it back?

I would like to send all the GPS Coordinates to one specific XBee module and this one module needs to be able to send information back to the sending modules individually as well. So I basically have:

XBee 1: Send GPS Coordinates to XBee 3
XBee 2: Send GPS Coordinates to XBee 3
XBee 3: Receive all messages and once within certain range to XBee 2 -> send message to XBee 2.

So summing up, most of the time it is only transmitting to XBee module 3. I suppose I could hav the program keep track of which module it is sending to and then only change it as needed. This should get rid of the timing issues.

Thanks again.
3  Using Arduino / Project Guidance / Setting XBee AT commands as background process? on: February 11, 2013, 12:59:33 pm
Hi,

I am currently working on a project where I would like to define what XBee module to send GPS coordinates to. I am currently able to do this using the following code:

Code:
//Send the GPS coordinates via XBEE to other modules
void sendGPS(){
  boolean OK = false;
  char buf[10]; //buffer to hold the data being converted
  //determine which module this is
  if(thisModule == 'A'){
    if(mothershipNew){ //make sure new data has been recieved before printing
      while(OK == false){ //keep trying to get into command mode
        Serial.println("-----------------------");
        Serial2.print("+++"); //get into command mode
        delay(1200); //wait for command mode
        OK = false;
        while(Serial2.available() > 0){
          Serial.write(Serial2.read()); //print response
          OK = true; //once responce received, continue
        }
        if(OK){
          Serial.println();
          Serial2.println("ATDN RESCUE"); //configure to send to RESCUE
          delay(100);//wait for command to set
          while (Serial2.available() <= 0) {
            Serial.write(Serial2.read());  
            //get response
          }
          Serial.println();
          Serial2.write(thisModule); //Print the Module Identifier
          Serial2.write(44);
          Serial2.write(ltoa(latitudeMothership, buf, 10)); //send as array of char
          Serial2.write(44);
          Serial2.write(ltoa(longitudeMothership, buf, 10));
          Serial2.write(10);
        }
        delay(1000);
      }
    }
  }
  else if(thisModule == 'B'){
    if(rescueNew){ //make sure new data has been recieved before printing
      while(OK == false){ //keep trying to get into command mode
        Serial.println("-----------------------");
        Serial2.print("+++"); //get into command mode
        delay(1200); //wait for command mode
        OK = false;
        while(Serial2.available() > 0){
          Serial.write(Serial2.read()); //print response
          OK = true; //once responce received, continue
        }
        if(OK){
          Serial.println();
          Serial2.println("ATDN RESCUE"); //configure to send to RESCUE
          delay(100);//wait for command to set
          while (Serial2.available() <= 0) {
            Serial.write(Serial2.read());  
            //get response
          }
          Serial.println();
          Serial2.write(thisModule); //Print the Module Identifier
          Serial2.write(44);
          Serial2.write(ltoa(latitudeRescue, buf, 10)); //send as array of char
          Serial2.write(44);
          Serial2.write(ltoa(longitudeRescue, buf, 10));
          Serial2.write(10);
        }
        delay(1000);
      }
    }
  }
  else{
    if(victimNew){ //make sure new data has been recieved before printing
      while(OK == false){ //keep trying to get into command mode
        Serial.println("-----------------------");
        Serial2.print("+++"); //get into command mode
        delay(1200); //wait for command mode
        OK = false;
        while(Serial2.available() > 0){
          Serial.write(Serial2.read()); //print response
          OK = true; //once responce received, continue
        }
        if(OK){
          Serial.println();
          Serial2.println("ATDN RESCUE"); //configure to send to RESCUE
          delay(100);//wait for command to set
          while (Serial2.available() <= 0) {
            Serial.write(Serial2.read());  
            //get response
          }
          Serial.println();
          Serial2.write(thisModule); //Print the Module Identifier
          Serial2.write(44);
          Serial2.write(ltoa(latitudeVictim, buf, 10)); //send as array of char
          Serial2.write(44);
          Serial2.write(ltoa(longitudeVictim, buf, 10));
          Serial2.write(10);
        }
        delay(1000);
      }
    }
  }
  
}


The problem with this code is that it is obviously hindering the rest of my code from executing by causing roughly a two to three second delay. This is due to it waiting for a response from the XBee stating that it got into the programming mode and then delaying to get out of the programming mode. NOTE: I have tried sending the XBee the command "ATCN" to drop out of the command mode to quicken the process, but this resulted in the XBee sending "ATCN" to the other XBee module. I also need to wait a second for the XBee to enter the programming mode according to another blog I read about this.

My question is, is there any way I could make this happen in the background because I need my arduino to update the motor controller I am going to implement? A two second delay would cause my robot to turn left and right uncontrollably instead of heading in a straight line.

I generally don't like to use delay functions in my code and would be more than happy to try another approach that doesn't involve waiting.

Thanks in advance

P.S.

A little more info on the project:
Each Arduino / XBee receives GPS coordinates which it then sends to the other unit. One unit is supposed to track and go to the other unit. I am using an Arduino Mega 2560 and and Arduino Uno (with SoftwareSerial).
4  Using Arduino / Interfacing w/ Software on the Computer / Re: Interfacing with Linux on: January 30, 2011, 11:41:44 am
I am also having this same issue, but only with the newer Arduino MEGA 2560. So far I have not encountered this problem with my older Arduino MEGA 1280. The strange thing is that this rarely happens on my xp system, only linux. I am using the ArduinoIDE0021 and running UBUNTU Linux.

Have you tried to add a delay after the serailRead/Write? I believe that sometimes fixed the problem, although I am not a hundred percent sure as it was a awhile ago since I used that board.

5  Forum 2005-2010 (read only) / Syntax & Programs / Re: Alternative to delay() during interrupt on: January 03, 2011, 08:52:04 pm
Thank you for the reply Lefty,
I have heard that before. I guess Ill just have to keep my project a little less fancy, or find another way of executing my code. I think I might just end up causing the interrupt to change the value of an int. In my main loop ill have it check if the int is 0 or 1 before it executes the other commands. And if the interrupt was executed, the int will be 1, so then it'll execute the above function and return the value of int to 0.

I love how there are so many ways of achieving ones goal in programming. Its just a pain to find one which works correctly, but efficiently.  smiley

Thanks again,
Firestork
6  Forum 2005-2010 (read only) / Syntax & Programs / Alternative to delay() during interrupt on: January 03, 2011, 08:15:19 pm
Hi all,

I have an interrupt which is supposed to cycle through different modes on my LCD screen. The problem I have is that while my interrupt is activated, I would like the LCD screen to display which options you are running through. My LCD screen requires the program to have a delay after the data has been written to the LCD because I also have a clearLCD function, so the user wouldn't be able to see what is written as it is cycling through the program too fast. So what I am asking is how can I replace the delay function so that the LCD will display the options because I know that you cant have delay functions in an interrupt?
Here is my function which is called when the interrupt is activated:
Code:
void tripuino::funkvor(volatile int *function){
  int pot;
    while(digitalRead(4) == LOW){          //While "Enter not being pressed.."
      pot = analogRead(0);
      if(pot <= 1023 && pot >= 774){        //value between 1023 - 774 display 0 etc..
        *function = 1;
        lcd.clearLCD();
        lcd.goTo(0);
        Serial.print("Choose Function:");
        lcd.goTo(18);
        Serial.print("Speed (KM/H)");    
        //delay(100) replacement here
      }
      else{
        if(pot < 774 && pot >= 525){
          *function = 2;
          lcd.clearLCD();
          lcd.goTo(0);
          Serial.print("Choose Function:");
          lcd.goTo(19);
          Serial.print("Speed (MPH)");
         //delay(100) replacement here
        }
        else{
          if(pot < 525 && pot >= 190){
            *function = 3;
            lcd.clearLCD();
            lcd.goTo(0);
            Serial.print("Choose Function:");
            lcd.goTo(16);
            Serial.print("Avg.Speed (KM/H)");
            //delay(100) replacement here
          }
          else{
            if(pot < 190 && pot >= 55){
              *function = 4;
              lcd.clearLCD();
              lcd.goTo(0);
              Serial.print("Choose Function:");
              lcd.goTo(16);
              Serial.print("Avg. Speed (MPH)");
              //delay(100) replacement here
            }
            else{
              if(pot < 55 && pot >= 28){
                *function = 5;
                lcd.clearLCD();
                lcd.goTo(0);
                Serial.print("Choose Function:");
                lcd.goTo(17);
                Serial.print("Distance (KM)");
                //delay(100) replacement here
              }
              else{
                if(pot < 28 && pot >= 9){
                  *function = 6;
                  lcd.clearLCD();
                  lcd.goTo(0);
                  Serial.print("Choose Function:");
                  lcd.goTo(17);
                  Serial.print("Distance (MI)");
                 //delay(100) replacement here
                }
                else{
                  if(pot < 9 && pot >= 4){
                    *function = 7;
                    lcd.clearLCD();
                    lcd.goTo(0);
                    Serial.print("Choose Function:");
                    lcd.goTo(18);
                    Serial.print("Travel Time");
                   //delay(100) replacement here
                  }
                  else{
                    if(pot == 3){
                      *function = 8;
                      lcd.clearLCD();
                      lcd.goTo(0);
                      Serial.print("Choose Function:");
                      lcd.goTo(20);
                      Serial.print("Security");
                      //delay(100) replacement here
                    }
                    else{
                      if(pot == 2){
                        *function = 9;
                        lcd.clearLCD();
                        lcd.goTo(0);
                        Serial.print("Choose Function:");
                        lcd.goTo(17);
                        Serial.print("Security BETA");
                       //delay(100) replacement here
                      }
                      else{
                        if(pot == 1){
                          *function = 1;
                          lcd.clearLCD();
                          lcd.goTo(0);
                          Serial.print("Choose Function:");
                          lcd.goTo(17);
                          Serial.print("END - Go Back");
                         //delay(100) replacement here
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
}

Thanks in advance
7  Forum 2005-2010 (read only) / Syntax & Programs / Re: Restart loop after interrupt? on: December 31, 2010, 05:36:00 pm
Thank you marklar,

This is perfect, I do not have much time today, but ill try to play around with this tomorrow.

Happy New Year
8  Forum 2005-2010 (read only) / Syntax & Programs / Re: Restart loop after interrupt? on: December 29, 2010, 07:58:32 pm
Thanks for the help PaulS, but do you have a link to how I would go about this? I do not have much experience with interrupts. A simple example would do too.

Thanks,
Firestork
9  Forum 2005-2010 (read only) / Syntax & Programs / Restart loop after interrupt? on: December 29, 2010, 07:27:11 pm
Hi,
Does anyone know if it is possible to start a program from the beginning of the loop() function after an external interrupt has been executed instead of picking up where it left off?
I have a program which checks the speed of the car, distance traveled, average speed etc.. and when the interrupt is activated, it is supposed to toggle through the different modes. The problem I have is that if the car is standing still and the magnets are not passing the reed switch, I need to wait 6 seconds for each screen to advance. I would like to make it so that it advances instantaneously and causing the program to start from the beginning of the loop after the interrupt has been tripped would do this. If anyone knows of another solution that would work, please let me know and so I could try that.

Here is a link to my project so far: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1293063615
And the full code: http://ubuntuone.com/p/Vqh/


Also, is there any way I could write a cleaner version of this code? It is supposed to calculate the time it takes a magnet to make one revolution across a reed switch and if it exceeds 6 seconds, it should stop waiting and move on with the code. (Basically this is for a speedometer and if it takes more than 6 seconds it will display a zero speed) I was thinking of using an interrupt, but am not sure how to implement this. If anyone has a good example of using an interrupt like this that would be greatly appreciated. I did see something on timer interrupts and will try to find a better example on that. Am I heading in the right direction here, or is there a better way?
Code:
void tripuino::rech(unsigned long *timestart, unsigned long *timeend, int *stehen){
  unsigned long check;
  check = millis();
  while (digitalRead(3) == HIGH){
    if((millis() - check) > 6000){
      *timestart = 0;
      *timeend = 40000;
      *stehen = 0;
      break;
    }
    }
    *timestart = millis();
    while (digitalRead(3) == LOW){
      if((millis() - check) > 6000){
      *timestart = 0;
      *timeend = 40000;
      *stehen = 0;
      break;
    }
    }
    while (digitalRead(3) == HIGH){
      if((millis() - check) > 6000){
      *timestart = 0;
      *timeend = 40000;
      *stehen = 0;
      break;
    }
    }
    *timeend = millis();
}

Thanks in advance,

Firestork
10  Forum 2005-2010 (read only) / Syntax & Programs / Re: Random nunbers displaying on: December 25, 2010, 07:47:44 pm
Thank you Msquare, that solved my problem, but all I want are four values to be stored, so why do I need 5? I dont understand.
11  Forum 2005-2010 (read only) / Syntax & Programs / Random nunbers displaying on: December 25, 2010, 07:18:16 pm
Hi,

I have been working on this code here trying to create a GUI for the user to input their PIN. Every time the user gets to the third number, the lcd displays random numbers (See video link).

Any ideas? I am 99.99% sure it has nothing to do with my lcd library as I have used it for other programs without problems, but ill post the code to that just in case.

I think the problem may lie outside the while loop, but to tell you the truth I am completely lost right now. I might have just placed a bracket in the wrong spot or done some other stupid mistake.

Any help is appreciated.

Video: http://ubuntuone.com/p/VMh/

Main program:
Code:
/*Sample code for the SerialLcd library which shows the time in millis on the top and bottom lines of the LCD.
 */
#include <Sparklcd.h>
Sparklcd lcd;


int inArray[3];

void setup()
{
  Serial.begin(9600);
  pinMode(0, INPUT); //POT input
  pinMode(4, INPUT);  //"Enter" key
  lcd.backlightOn();
  Serial.print("     ");
  delay(500);
}

void loop(){  

  input(inArray);
}

void input(int inArray[0]){
  int pot;
  int i;
  lcd.clearLCD();
  lcd.goTo(3);
  Serial.print("Enter PIN:");
  lcd.goTo(20);
  Serial.print("_ _ _ _");
  delay(500);
  
  for(i=0; i<4; i++){
    while(digitalRead(4) == LOW){          //While "Enter not being pressed.."
      pot = analogRead(0);
      if(pot <= 1023 && pot >= 774){        //value between 1023 - 774 display 0 etc..
        inArray[i] = 0;
        lcd.clearLCD();
        lcd.goTo(3);
        Serial.print("Enter PIN:");
        lcd.goTo(23);
        Serial.print(inArray[i]);
        delay(100);    
      }
      else{
        if(pot < 774 && pot >= 525){
          inArray[i] = 1;
          lcd.clearLCD();
          lcd.goTo(3);
          Serial.print("Enter PIN:");
          lcd.goTo(23);
          Serial.print(inArray[i]);
          delay(100);
        }
        else{
          if(pot < 525 && pot >= 190){
            inArray[i] = 2;
            lcd.clearLCD();
            lcd.goTo(3);
            Serial.print("Enter PIN:");
            lcd.goTo(23);
            Serial.print(inArray[i]);
            delay(100);
          }
          else{
            if(pot < 190 && pot >= 55){
              inArray[i] = 3;
              lcd.clearLCD();
              lcd.goTo(3);
              Serial.print("Enter PIN:");
              lcd.goTo(23);
              Serial.print(inArray[i]);
              delay(100);
            }
            else{
              if(pot < 55 && pot >= 28){
                inArray[i] = 4;
                lcd.clearLCD();
                lcd.goTo(3);
                Serial.print("Enter PIN:");
                lcd.goTo(23);
                Serial.print(inArray[i]);
                delay(100);
              }
              else{
                if(pot < 28 && pot >= 9){
                  inArray[i] = 5;
                  lcd.clearLCD();
                  lcd.goTo(3);
                  Serial.print("Enter PIN:");
                  lcd.goTo(23);
                  Serial.print(inArray[i]);
                  delay(100);
                }
                else{
                  if(pot < 9 && pot >= 4){
                    inArray[i] = 6;
                    lcd.clearLCD();
                    lcd.goTo(3);
                    Serial.print("Enter PIN:");
                    lcd.goTo(23);
                    Serial.print(inArray[i]);
                    delay(100);
                  }
                  else{
                    if(pot == 3){
                      inArray[i] = 7;
                      lcd.clearLCD();
                      lcd.goTo(3);
                      Serial.print("Enter PIN:");
                      lcd.goTo(23);
                      Serial.print(inArray[i]);
                      delay(100);
                    }
                    else{
                      if(pot == 2){
                        inArray[i] = 8;
                        lcd.clearLCD();
                        lcd.goTo(3);
                        Serial.print("Enter PIN:");
                        lcd.goTo(23);
                        Serial.print(inArray[i]);
                        delay(100);
                      }
                      else{
                        if(pot == 1){
                          inArray[i] = 9;
                          lcd.clearLCD();
                          lcd.goTo(3);
                          Serial.print("Enter PIN:");
                          lcd.goTo(23);
                          Serial.print(inArray[i]);
                          delay(100);
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
    if(i == 0){                        //If "Enter" pressed
      lcd.clearLCD();
      lcd.goTo(3);
      Serial.print("Enter PIN:");
      lcd.goTo(20);
      Serial.print(inArray[i]);
      lcd.goTo(22);
      Serial.print("_ _ _");
      delay(500);
      lcd.clearLCD();
      lcd.goTo(3);
      Serial.print("Enter PIN:");
      lcd.goTo(20);
      Serial.print("*");
      lcd.goTo(22);
      Serial.print("_ _ _");
      delay(100);
    }
    else{
      if(i == 1){
        lcd.clearLCD();
        lcd.goTo(3);
        Serial.print("Enter PIN:");
        lcd.goTo(20);
        Serial.print("*");
        lcd.goTo(22);
        Serial.print(inArray[i]);
        lcd.goTo(24);
        Serial.print("_ _");
        delay(500);
        lcd.clearLCD();
        lcd.goTo(3);
        Serial.print("Enter PIN:");
        lcd.goTo(20);
        Serial.print("* *");
        lcd.goTo(24);
        Serial.print("_ _");
        delay(100);
      }
      else{
        if(i == 2){
          lcd.clearLCD();
          lcd.goTo(3);
          Serial.print("Enter PIN:");
          lcd.goTo(20);
          Serial.print("* *");
          lcd.goTo(24);
          Serial.print(inArray[i]);
          lcd.goTo(26);
          Serial.print("_");
          delay(500);
          lcd.clearLCD();
          lcd.goTo(3);
          Serial.print("Enter PIN:");
          lcd.goTo(20);
          Serial.print("* * *");
          lcd.goTo(26);
          Serial.print("_");
          delay(100);
        }
        else{
          lcd.clearLCD();
          lcd.goTo(3);
          Serial.print("Enter PIN:");
          lcd.goTo(20);
          Serial.print("* * *");
          lcd.goTo(26);
          Serial.print(inArray[i]);
          delay(500);
          lcd.clearLCD();
          lcd.goTo(3);
          Serial.print("Enter PIN:");
          lcd.goTo(20);
          Serial.print("* * * *");
          delay(500);
        }
      }
    }
  }
}



LCD .h:
Code:
/*Written by Frederick Hunter 17.12.2010 based on the Arduino.cc
website http://www.arduino.cc/playground/Learning/SparkFunSerLCD
*/
/*PRE & POST Conditions:
 * void selectLineOne();
 * PRE: NONE
 * POST: moves cursor to the first position in the top line
 *
 * void selectLineTwo();
 * PRE: NONE
 * POST: moves cursor to the first position on the bottom line
 *
 * void goTo(int position);
 * PRE: position is the block number you want to put the cursor to (0-15 is line 1 & 16-31 is line two, 31+ sets it back to 0)
 * POST: moves cursor to defined block position
 *
 * void clearLCD();
 * PRE: NONE
 * POST: erases everything on the LCD screen
 *
 * void backlighOn();
 * PRE: NONE
 * POST: Turns on the backlight
 *
 * void backlightOff();
 * PRE: NONE
 * POST: Turns the backlight off
 *
 * void serCommand();
 * PRE: NONE
 * POST: calls specified command
 */
 


#ifndef SPARKLCD_H
#define SPARKLCD_H

#include <WProgram.h>

class Sparklcd{
  public:
    Sparklcd();
    ~Sparklcd();
    void selectLineOne();
    void selectLineTwo();
    void goTo(int position);
    void clearLCD();
    void backlightOn();
    void backlightOff();
    void serCommand();
};

#endif

And Lcd.cpp
Code:
/*Written by Frederick Hunter 17.12.2010 based on the Arduino.cc
website http://www.arduino.cc/playground/Learning/SparkFunSerLCD
*/
#include "WProgram.h"
#include "Sparklcd.h"

Sparklcd::Sparklcd(){
}
Sparklcd::~Sparklcd(){
}

void Sparklcd::selectLineOne(){  
   Serial.print(0xFE, BYTE);  
   Serial.print(128, BYTE);    
}
void Sparklcd::selectLineTwo(){  
   Serial.print(0xFE, BYTE);  
   Serial.print(192, BYTE);  
}
void Sparklcd::goTo(int position) {
if (position<16){
  Serial.print(0xFE, BYTE);  
  Serial.print((position+128), BYTE);  
}
else if (position<32){
  Serial.print(0xFE, BYTE);  
  Serial.print((position+48+128), BYTE);  
}
else {
  goTo(0);
}
}

void Sparklcd::clearLCD(){
   Serial.print(0xFE, BYTE);  
   Serial.print(0x01, BYTE);
}
void Sparklcd::backlightOn(){
    Serial.print(0x7C, BYTE);  
    Serial.print(157, BYTE);  
}
void Sparklcd::backlightOff(){  
    Serial.print(0x7C, BYTE);  
    Serial.print(128, BYTE);    
}
void Sparklcd::serCommand(){  
  Serial.print(0xFE, BYTE);
}

12  Forum 2005-2010 (read only) / Syntax & Programs / Exit function after specified time on: December 20, 2010, 05:19:05 pm
Hi,

Im not sure if someone already asked this before, but I was wondering if I could break from a function if the function doesn't fully execute in say 6 seconds.

Basically this is the function which will be running to calculate the time it takes a magnet to pass once over a reed switch:

Code:
void tripuino::rech(unsigned long *timestart, unsigned long *timeend){
    while (digitalRead(3) == HIGH){
    }
    *timestart = millis();
    while (digitalRead(3) == LOW){
    }
    while (digitalRead(3) == HIGH){
    }
    *timeend = millis();
}
I want the function to stop executing if it takes longer than six seconds to indicate that the speed is roughly zero in the rest of my code. Would I need to use an interrupt or is there another way of achieving my goal?

Thanks in advance
13  Forum 2005-2010 (read only) / Syntax & Programs / Re: Passing arguments to interrupts? on: December 18, 2010, 06:53:15 pm
Thank you for the quick reply AWOL. In case anyone was wondering, I got around this by not defining the interrupt in my library, but instead creating the function in my main program and declaring the variable I wanted to change as a global variable.
14  Forum 2005-2010 (read only) / Syntax & Programs / Passing arguments to interrupts? on: December 18, 2010, 06:28:06 pm
Hi everyone,

I am now on the last leg of my library for a trip computer I have been working on for my car. The only thing holding me back now is that I cannot seem to pass a pointer to an interrupt I have made in my library. Does anyone know if its even possible to pass arguments to an interrupt function? Basically what I am looking to do is add 1 to a pointer to an int I have defined in my main program.

this is in my setup function in the main program: attachInterrupt(0, vor, FALLING);

and the prototype for vor is :  void vor(volatile int *function);

I have tried calling : attachInterrupt(0, vor(&function), FALLING);
too, but they both always return the error vor was not declared in this way.

FYI: volatile int function = 1;   is declared before the setup() function in my main code window.

If you need the complete code, please let me know and I will post a link, but I guess this is more of a general question.

Thanks in advance.
15  Forum 2005-2010 (read only) / Syntax & Programs / Re: Interrupt only resets arduino on: October 25, 2010, 08:47:53 am
Sorry about the late reply,

Last week I realized that was exactly my problem. I hadn't put a resistor before the ground and it was causing my arduino to short out. It works great now.

Thanks
Pages: [1] 2 3 ... 5