Go Down

Topic: Arduino Yun and Uno comparison  (Read 396 times) previous topic - next topic

Filip88

Hi,

i have simple interrupt code witch works great on arduino Uno board pins 2 and 3, if arduino Yun also has interrupts on pins 2 and 3 why that same code wont show same results, i know that two board use different controller. but INT0 and INT1 are the same.

Uno                      Yun
int1 pin3               int1 pin2
int0 pin2               int0 pin3

Code: [Select]


attachInterrupt(0, brojacA, RISING); //pin2
attachInterrupt(1, brojacB, RISING); //pin3



i just switch pins on Yun and instead of getting to count pulses from optical sensor on serial monitor i can only see values 0 and 65536

this is whole code

Code: [Select]


volatile unsigned int broji = 0;

void setup() {
Serial.begin(9600);


pinMode(2, INPUT);
pinMode(3, INPUT);

//pin 2
attachInterrupt(0, brojacA, RISING);
//pin 3
attachInterrupt(1, brojacB, RISING);
}

void loop() {
 
Serial.println(broji);
}


void brojacA(){
  if(digitalRead(3) == LOW){
    broji++;
  }else{
    broji--;
  }
}


void brojacB(){
  if(digitalRead(2) == LOW){
    broji--;
  }else{
    broji++;
  }
}



if someone can help it will be much appreciated.

artisticforge

Hi,

i have simple interrupt code witch works great on arduino Uno board pins 2 and 3, if arduino Yun also has interrupts on pins 2 and 3 why that same code wont show same results, i know that two board use different controller. but INT0 and INT1 are the same.

Uno                      Yun
int1 pin3               int1 pin2
int0 pin2               int0 pin3

Code: [Select]


attachInterrupt(0, brojacA, RISING); //pin2
attachInterrupt(1, brojacB, RISING); //pin3





i just switch pins on Yun and instead of getting to count pulses from optical sensor on serial monitor i can only see values 0 and 65536

this is whole code

Code: [Select]


volatile unsigned int broji = 0;

void setup() {
Serial.begin(9600);


pinMode(2, INPUT);
pinMode(3, INPUT);

//pin 2
attachInterrupt(0, brojacA, RISING);
//pin 3
attachInterrupt(1, brojacB, RISING);
}

void loop() {
 
Serial.println(broji);
}


void brojacA(){
  if(digitalRead(3) == LOW){
    broji++;
  }else{
    broji--;
  }
}


void brojacB(){
  if(digitalRead(2) == LOW){
    broji--;
  }else{
    broji++;
  }
}



if someone can help it will be much appreciated.

It is 0200 hrs here and I will try it in the morning.

Which Tun are you using? Arduino.cc or Arduino.org Yun?
Which version of Arduino IDE are you using?
Operating system? Linux, Macosx or Windows ?

Filip88

windows 10

i dont know if it is cc or org

IDK ver is 1.8.5

Zaszigre

Hello,

I think you could use the function digitalPinToInterrupt(pin). It could work this way:

Code: [Select]
attachInterrupt(digitalPinToInterrupt(2), brojacA, RISING);
attachInterrupt(digitalPinToInterrupt(3), brojacA, RISING);

Go Up