Does anyone know what happens to the I/O pins when your put the ATMega328 to sleep? I need to pull a pin high, go to sleep and leave it HIGH while it is asleep.
Do the different sleep modes have different effects on the pins?
So the arduino sends pin 2 HIGH, this triggers the second ATmega328 to go to sleep
@Coding Badly: why does it consume power to hold a pin high? I thought it would consume power if it sources current or if it switches. If there is no load, then it should not consumer power. Or am I mistaken?
Btw: last weekend I was told by a micro controller professional that the current consumption caused by pins can be quite counterintuitive. There is at least one microcontroller that will consumer least power while sleeping if all pins are set to output high. This is despite the fact that the pins in questions could be tristated.
If I send the pin LOW to go into a powerdown sleep, As far as I understand, I can't tell the ATMega328 to wake on the pin going HIGH. Only when it goes LOW.
Using a pin-change interrupt should solve the problem.The best plan is to first get the application working. You can play with HIGH = SLEEP versus LOW = SLEEP after everything else is functional.
/* Now it is time to enable an interrupt. In the function call * attachInterrupt(A, B, C) * A can be either 0 or 1 for interrupts on pin 2 or 3. * * B Name of a function you want to execute while in interrupt A. * * C Trigger mode of the interrupt pin. can be: * LOW a low level trigger * CHANGE a change in level trigger * RISING a rising edge of a level trigger * FALLING a falling edge of a level trigger * * In all but the IDLE sleep modes only LOW can be used. */ /* * The 5 different modes are: * SLEEP_MODE_IDLE -the least power savings * SLEEP_MODE_ADC * SLEEP_MODE_PWR_SAVE * SLEEP_MODE_STANDBY * SLEEP_MODE_PWR_DOWN -the most power savings */
You may be able to reduce or eliminate the sleeping power consumption by enabling the pullup resistor on the input (slave) side. When the master sinks (turns the output low) to wake the slave, current would flow. When the master sources to sleep the slave, both sides would be at the same potential so no current would flow. I think I have that correct.