Here is my code:
const byte ledPin = 13;
const byte interruptPin = 2;
volatile byte state = LOW;
void setup() {
Serial.begin(115200);
pinMode(ledPin, OUTPUT);
pinMode(interruptPin, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(interruptPin), blink, CHANGE);
}
void loop() {
delay(5000);
Serial.print("state = ");
Serial.println(state);
digitalWrite(ledPin, state);
}
void blink() {
Serial.print(" interruptPin = ");
Serial.println(interruptPin);
Serial.print("ledPin = ");
Serial.println(ledPin);
state = !state;
}
Here is my serial monitor output:
state = 0
state = 0
interruptPin = 2
ledPin = 13
state = 1
interruptPin = 2
ledPin = 13
state = 0
state = 0
state = 0
Can someone tell me how I can print the Boolean values for Pins 13 and 2 instead of the pin numbers.