Hi.
I am using an arduino mega and limit switches.
I have pins corresponding to each of my (8) limit switches: pins 40 - 47.
I can't change these pins given the project rn, but I need to enable interruptions on each of these pins. I'm trying to set it up so that when a limit switch is pressed, I use an interruption (the code will be the same for each interruption for these switches, which I think is good b/c the method I'm trying to use allows for two or more pins to share the same routine....
I'm not sure which service to use? Apparently my options are:
ISR (PCINT0_vect) pin change interrupt for D8 to D13
ISR (PCINT1_vect) pin change interrupt for A0 to A5
ISR (PCINT2_vect) pin change interrupt for D0 to D7
I really don't get how they implemented this....Please help!
Namely, I don't understand these functions:
void pciSetup(byte pin)
{
*digitalPinToPCMSK(pin) |= bit (digitalPinToPCMSKbit(pin)); // enable pin
PCIFR |= bit (digitalPinToPCICRbit(pin)); // clear any outstanding interrupt
PCICR |= bit (digitalPinToPCICRbit(pin)); // enable interrupt for the group
}
// Use one Routine to handle each group
ISR (PCINT0_vect) // handle pin change interrupt for D8 to D13 here
{
digitalWrite(13,digitalRead(8) and digitalRead(9));
}
ISR (PCINT1_vect) // handle pin change interrupt for A0 to A5 here
{
digitalWrite(13,digitalRead(A0));
}
ISR (PCINT2_vect) // handle pin change interrupt for D0 to D7 here
{
digitalWrite(13,digitalRead(7));
}
What am I supposed to change? What function is called for when the interrupt is activated, where's the code?
I have pins corresponding to each of my limit switches: pins 40 - 47.
I can't change these pins given the project rn, but I need to enable interruptions on each of these pins.
I don't think that any form of interrupt (neither "external" nor "pin change) is supported on pins 40-47 (that's a couple pins from PORTG and six from PORTL)
The MEGA processor only has pin change interrupts on 24 pins (all of PORTB, PE0, PJ0..6, all of PORTK)
You'll need to poll...
I have decided not to have all the mega boards in one place, as I said earlier. I will have each board as close as possible to the components but it must be possible to disconnect the component if needed!
I like connect as bellow:
1.) Connect the Solid core for the component.
question A.) Am I need some soft of Shrink
Tubing for the Rotary Switches - 12 pos? (The pins is closes to each other so I
thinking of the magnetic field)
3.) The other end of the 2 pin push quick cable connector have the cable which is connected into the board. This wire is like this sort V-TEC Jumper Wires Pre-crimped Terminaler (FeMale)
The bad Solid core cable is more than maybe 2 inch?! They should not be bent at all!
I have started a new topic. I think my toppic is handle almost the same question? Interruptions
Best regards Fredrik
Ah. Well why do you think anyone would be interested in a 2 year old thread on a similar subject now? You are dangerously close to duplicate posting which is not allowed here.