0

I have an arduino mini with an ultrasonic sensor conected to the pins 2 and 3, and a RGB LED connected to the 4,5, and 6, I want to include a wake up and sleep functionality that wakes up when receive a high signal in another pin as 7.

I have seen that normaly the pins for that are 2 and 3, as in the arduino web: Arduino sleep web

But can it be done with another pin?

1

As well as the normal external interrupts INT0 and INT1 you can also wake the chip through a variety of other interrupts. One of those is the pin change interrupt.

In the datasheet is a table of what is available in the different sleep modes, and what can wake you from that sleep mode. I have compressed the table to remove a lot of the stuff you don't care about at the moment and just show the "wake-up sources":

enter image description here

As you can see both INT and PCINT can wake from all modes (along with TWI [Wire.h] slave mode address matching).

The note (3) on the table just says that for INT0 and INT1 it must be a LOW level interrupt, not a RISING or FALLING. No mention is made of the type of interrupt for PCINT.

So yes, since pin 7 has PCINT facilities (all pins on the ATMega328P have PCINT) you can configure that as a wake-up source and wake the MCU using pin 7.

1

Arduino Mini has only two interrupt capable pins: 2 and 3. You have to move your sensor to other pin.

From the AtMega328p datasheet:

If a level triggered interrupt is used for wake-up from Power-down, the required level must be held long enough for the MCU to complete the wake-up to trigger the level interrupt. If the level disappears before the end of the Start-up Time, the MCU will still wake up, but no interrupt will be generated. The start-up time is defined by the SUT and CKSEL Fuses.

  • You forgot PCINT... – Majenko Oct 25 '17 at 10:18
  • @Majenko. You are right. Your answer is better. What do i do? – user31481 Oct 25 '17 at 10:26
  • There's not a lot you can do besides plagiarise ;) It's up to the OP to do whatever he fancies. – Majenko Oct 25 '17 at 10:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.