Alguien sabe como se programa una interrupcion en arduino ,ya que cuando utilizo attachinterrupt(0,codigo de la interrupcion,LOW) pero cuando invoco una funcion que yo hice dentro del codigo de la interrupcion no funciona el codigo, compila y todo pero no me sale lo q espero. Gracias
English
somebody know, how i can use the attachinterrupt(pin, code interrupt, low) because, i can not declare the another function inside code interrupt.
void setup (){
Wire.begin(); //iniciar el bus de I2C
Serial.begin(9600);
pinMode(INTERRUPTPIN, INPUT);
initGyro();
sei();
attachInterrupt(0,interruptfinal,LOW);
}
void interruptfinal() {
byte aux=readByte(GYRO, G_INT_STATUS);
if (aux==00000001 || aux==00000101){
readFrom(GYRO, G_INT_STATUS, 8, gyro);
x = ((gyro[2] << | gyro[3]);
y = ((gyro[4] << | gyro[5]);
z = ((gyro[6] << | gyro[7]);
temp = (gyro[0] << | gyro[1];
void setup (){
Wire.begin(); //iniciar el bus de I2C
Serial.begin(9600);
pinMode(INTERRUPTPIN, INPUT);
initGyro();
sei();
attachInterrupt(0,interruptfinal,LOW);
}
void interruptfinal() {
byte aux=readByte(GYRO, G_INT_STATUS);
if (aux==00000001 || aux==00000101){
readFrom(GYRO, G_INT_STATUS, 8, gyro);
x = ((gyro[2] << | gyro[3]);
y = ((gyro[4] << | gyro[5]);
z = ((gyro[6] << | gyro[7]);
temp = (gyro[0] << | gyro[1];
Pues quitando el hecho que estas usando la libreria Wire desde dentro de una interrupcion, y estas haciendo una espera activa que consume relativamente mucha CPU... Es muy probable que tengas las interrupciones enmascaradas y que nunca le llegue al micro la interrupcion del I2C.