Offline
Newbie
Karma: 0
Posts: 3
|
 |
« on: February 08, 2011, 04:23:08 pm » |
buenas
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 readFrom(int device, byte address, int num, byte buff[]) { Wire.beginTransmission(device); Wire.send(address); Wire.endTransmission(); //RESTART CONDITION Wire.beginTransmission(device); Wire.requestFrom(device, num); int i = 0; while(Wire.available()) { buff = Wire.receive(); i++; } Wire.endTransmission(); }
|