• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

atmega8 (sleep mode) hellp


New Member
Hi everyone!

I have a circuit with atmega8 + basic . I want to use "sleep mode" and need your help.
my cricuit have a keyboard 3*4 . my microcontroler wait for recive a nomber from keyboard whole time, I want my microcontroler go to sleep mod when not switched any keyboard figure . how can i use "sleep mode" in progeram (basic) ?

Many thanks in advance


Active Member
Might want to post what you have done so far and naming the basic compiler can't hurt

Have you read up on the sleep command? You will get more help if you post the work you have already done, otherwise no one will do your project/homework for you.


New Member
Thanks mramos1
I use the bascom basic compiler
My project is simple digital key
In my pogeram I use the below command
So my microcontroller whole time wait for get a number
I want to add a “sleep command” to my program for reduce the
Power used by microcontroller .
I know there are some sleep commands for AVR microcontroller like as :
Also I use a internal crystal in program .
Thanks for ur reply


Active Member
Not up on that compiler. I use RVKBASIC from bastoc.com for AVR projects.

Are you trying to wake-up on a key-press? Really need to see a schematic. Maybe someone that knows bascom will pop in here. Or hit AVRfreaks.com.

If I get time I will see if I can get the manual for it online later. Always open to a new compiler.


New Member
thanks my friends : mramos & CCDCCD / this link not useful to learn how to use a sleep command in progeram.

I need to know which sleep command i should to use
I trying to wake-up on a key-press


New Member
here is another document from atmel which perfectly describes what you are looking for (only that the code is in assembly).


I don't use basic but for any compiler, for going to sleep mode you have to load the MCUCR register of atmega with appropriate value to select one of the five sleep modes: standby, power-down, power-save, idle or ADC noise reduction mode (refer to datasheet for MCUCR bits description)
for your application, you can load MCUCR with 0xa0 or 0xb0 for power-down or power-save mode respectively and enable external interrupt.
After setting MCUCR, just put the SLEEP instruction in your code where ever you want the controller to go to sleep.
the controller will wake-up whenever the external interrupt signal is applied (i.e. a key is pressed).

Design with Microcontrollers


Well-Known Member
Most Helpful Member
Last edited:

Latest threads

EE World Online Articles