how to make a attiny85 go to sleep?

hello is there a way to make a attiny85 go to sleep mode or idle mode so it can take less power to keep the batteries from dieing out? and a way to make it wake up is when a button is pressed?

https://gist.github.com/JChristensen/5616922#file-sleep_attinyx5-ino

Yes, a simple search of the forum with the search term "Sleep + Tiny85" returned several answers.. This appears to be good and it is well tested and documented. I know the author.. slightly.. http://forum.arduino.cc/index.php?topic=226238.msg1637422#msg1637422

Doc Note: Jacks reference is a GREAT starting point... [Doc]

Jack thank you what i was trying to do is take as little power as i can while keeping the attiny85 in sleep or idle mode something i was going to use a button to wake it up just for a brief second or less then that but i forgot i had some PIR sensors so what i would like to do is add that to this project so when someone walks past it the attiny comes out of sleep mode or idle mode and turns on a led problem is The PIR sensor takes power trying to make the battery last a long time its a 4.5v battery pack 3 double A batteries. trying to get it to last months if can.will the sleep mode help it?

josephchrzempiec: Jack thank you what i was trying to do is take as little power as i can while keeping the attiny85 in sleep or idle mode something i was going to use a button to wake it up just for a brief second or less then that but i forgot i had some PIR sensors so what i would like to do is add that to this project so when someone walks past it the attiny comes out of sleep mode or idle mode and turns on a led problem is The PIR sensor takes power trying to make the battery last a long time its a 4.5v battery pack 3 double A batteries. trying to get it to last months if can.will the sleep mode help it?

Sleep mode will reduce power used by the microcontroller (power-down mode will save the most power, idle mode less so, see the datasheet).

Not knowing anything about this particular PIR sensor, it's hard to comment. If it can generate an interrupt, then it can bring the MCU out of sleep mode. If the sensor needs to be on continually, then it may draw too much power. I might consider having the MCU turn the sensor on and off at some regular interval, say half a second or whatever is just quick enough to catch someone walking by. If the sensor can be powered up and read in, say, a few milliseconds, then power use could be reduced by an order of magnitude, maybe more.

this is the one i got http://www.ebay.com/itm/5x-HC-SR501-Human-Motion-Sensor-Infrared-PIR-Detection-Module-Arduino-Adjustable-/251472266076?pt=BI_Security_Fire_Protection&hash=item3a8cea435c