Sleep mode problem via digital pin 9 arduino mega 2560

hi guys i have some problem
in my project(ardunio mega) sleep mode and wake up not worked via digital pin 1 or 9 i testet and sleep and wake up worked only via digital pin 52

i need use pin 9 from SET sleep mode
digital pin 9 is healthy
please help me for use pin 9 from sleep mode

void loop()
{// When the ignition switch is turned, executes the next two ifs 
if (ignition == true && digitalRead(9) == LOW) 
{ 

  ignition = false; 



display.ssd1306_command(SSD1306_DISPLAYOFF); 
  
  sleep_enable(); // enables the sleep mode
  set_sleep_mode(SLEEP_MODE_PWR_DOWN); // set the sleep mode
  cli();
  sleep_disable(); // disables the brown out detector to consume less power while sleeping
  sei();
  sleep_mode(); // microcontroller goes to sleep  
if (ignition == true && digitalRead(9) == HIGH) 
{ 
  ignition = false;    // this variable is needed in order to run once the code inside this if
  logohold = millis(); // hold the LOGO screen on, for 2 sec
  inst_disp = true;
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);           
  display.clearDisplay();                              
  display.drawBitmap(0, 0,  logo, 128, 64, WHITE);     
  display.display();                                   


  while (millis() - logohold < 2000) ;


void ignitionSignal() // this is called everytime the ingintion signal changes -- if the 
microcontroller is in sleep mode, it will wake up
{
  ignition = !ignition;
 }

Post complete code! The error is most probably in that part of the code you're hiding from us.

You definetly need to post the complete code.

Did you check the Mega pin out diagram, does pin 9 support interrupts and wake up from sleep ?

OK
i uploaded my project sketchMY PROJECT.ino (7.7 KB)

i uploaded my sketch
i know in ardunio uno mega2560 digital pin 2 and 3 supported interrupt
i uploaded my sketch to ardunio uno and wakeup and sleep mode worked via digital pin 9 but via ardunio mega not working via pin 9 why ?

Sigh ............. did you carry out the check suggested in post #3 ?

Does pin 9 on a Mega support interrupts ?

A clue; to wake up a processor from sleep, you need to use a pin that supports interrupts .....................

I researched this

in ARDUNIO uno & mega2560 Pin 9 has no interrupt،But I solved this problem with this command

attachPCINT(digitalPinToPinChangeInterrupt(ignition_pin), ignitionSignal, CHANGE);

i posted my sketch

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.