i am using the Arduino Duemilanaove Atmega 328
I am trying to send set up an interrupt to switch between routines.
5V signals are sent to the digitals as interupt signals.
I have used the 5V power supply from the board as the signal source.
I simply connected the output to input ports via a wire.
the code does not seem to switch between the routines when I pull the wire in and out (0V and 5V).
Is there a problem with my code or is it the way that I have connected the 5V signal.
The following is the code I used:
int pin = 13;
int inputpin = 2;
int sequence = 0;
void sub(){
sequence++;
if (sequence == 2) {
sequence = 0;
}
}
void setup() {
pinMode(pin, OUTPUT);
pinMode(inputpin, INPUT);
attachInterrupt(inputpin, sub, CHANGE);
}
void loop() {
if (sequence == 0) {
digitalWrite(pin, LOW);
}
else if (sequence == 1) {
digitalWrite(pin, HIGH);
}
}