A-Star 328PB and Pin-Change interrupts?

Have A6 & A7 (pin 19 & 22) been added to the ISR(PCINT1_vect) group in your Arduino Boards code V4.0.2?
For example, should this work on your A-Star328PB?

This is the example: Pin_Change_interrupt_LED from the PinChangeInterrupt v1.26 library
  Copyright (c) 2014-2015 NicoHood
  See the readme for credit to other people.

#include "PinChangeInterrupt.h"

// Choose a valid PinChangeInterrupt pin of your Arduino board
_#define pinBlink A7_ //My emphasis

void setup() {
  // set pin to input with a pullup, led to output
  pinMode(pinBlink, INPUT_PULLUP);

  // Manually blink once to test if LED is functional

  // Attach the new PinChangeInterrupt and enable event function below
  attachPCINT(digitalPinToPCINT(pinBlink), blinkLed, CHANGE);

void blinkLed(void) {
  // Switch Led state
  digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));

void loop() {
  // Nothing to do here


Pins A6 and A7 on the A-Star 328PB are defined as pins 20 and 21, respectively, as Arduino digital pins numbers. (You probably just made a typo.) For others following this discussion, you can find the pinout details for the A-Star 328PB in the top picture labeled “A-Star 328PB Micro pinout diagram” on the A-Star 328PB Micro’s category page.

As for your question, A6 and A7 are also known as PCINT26 and PCINT27 respectively. According to the “EXTINT - External Interrupts” section of the ATmega328PB datasheet, which is linked under the “Resources” tab on the A-Star 328PB’s product pages (e.g. A-Star 328PB Micro - 5V, 16MHz), those two pins use Pin Change Interrupt Request 3, not 1. If you are defining your own ISR, you would use PCINT3_vect. I did a quick test to see if your code will work on an A-Star 328PB. The program does not work. I suspect you’ll have to modify the library to add support for the ATmega328PB.

- Amanda

Thank you for your comments Amanda,

Good to have your confirmation that Pin Change Interrupt library example
DOES NOT work for the 328PB.
On a second attempt, I can confirm that A6 & A7 (in fact all Port E pins

  • TQFP pins 3, 6, 19 & 22) can be programmed with the Ardiono IDE.
    Hope the sample below could help others?

Regards, Martin

//**** Connect switch between CPU Pin 22 and ground ******/

void setup()
   pinMode(A7, INPUT_PULLUP);       //TQFP Chip pin 22
   pinMode(LED_BUILTIN, OUTPUT);    //For diags ...

   /******  Setup Interrupt ****************
       ISR Code is at end if sketch, under loop()
   PCICR  |= 0b00001000;  // Enables Port E Pin Change Interrupts
   PCMSK3 |= 0b00001000;  // Enable Pin Change Interrupt on PE3 (aka A7, 
TQFP pin 22)

   // Manually blink LED once to test if LED is functional
   digitalWrite(LED_BUILTIN, HIGH);
   digitalWrite(LED_BUILTIN, LOW);

void loop()
   // Nothing to do here ...

    digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN)); //Toggle LED 
for feedback...

Thanks for sharing your code! I’m sure others will find it quite helpful.

- Amanda