i tried adding PCINT0 as a Pin Change Interrupt to wake up the chip but it made the board go crazy when there is no light.
i have looked in to the attiny 85 data sheet and it looks like you can't use PCINT0 to wake up to a specific voltage. plus photocell (CdS photoresistor) change the voltage depending on the light so i don't think i can use watchdog timer with my circuit to do what i want it to do. =(
He's already got all the code he needs, posted at the start of the thread.
I really don't know where the problem is.
the problem is that using a photocell as an interrupt is not a good idea because the voltage is not stable at all (even a little change in light will trigger the interrupt) plus i want the interrupt to happen on all 3 analog pins
what i want is that when the voltage on the photocell connected interrput pins reaches a specific voltage (and only that specific voltage) it wakes up.... lower than that specific voltage it stays in sleep mode
the code in Christensens demo sleep wakes up the chip by using a switch which is ok since the voltage is stable
if (there is light (at a specific value))
then beep
delay for 4 secs (or sleep for 4 secs)
then system goes to sleep but can wake up again if there is light;
if there is no light then stay sleeping till light is detected (at specific value)
the problem with the code you wrote is that after sleeping for 4 secs it checks for light and if there is no light then it will go back to sleep for another 4 secs... so during those 4 secs if there is light the system won't do anything.
only after it beeps the system should shut down for 4 secs....other than that it should wake up if there is light
iA2K:
what i want is that when the voltage on the photocell connected interrput pins reaches a specific voltage (and only that specific voltage) it wakes up.... lower than that specific voltage it stays in sleep mode
You will need to use an analog comparator to condition the photocell output to trigger at a certain reference voltage level.
what i want is that when the voltage on the photocell connected interrput pins reaches a specific voltage (and only that specific voltage) it wakes up.... lower than that specific voltage it stays in sleep mode
You will need to use an analog comparator to condition the photocell output to trigger at a certain reference voltage level.
it look alike a analogue comparator is the way to go....thank you
I mentioned the solution to that in the second post.
like i told you before using a photocell as an interrupt turns out to be a bad idea.
Why would a 4 second delay matter?
Maybe you could tell us what sort of light it is, how fast it changes, etc.
(or anything at all about what it is you're actually trying to achieve...)
those 4 secs are really essential to my system... (I'm trying to build a light installation made of many individual lights, after a light lights up it shouldn't do anything for 4 secs)
Take a look at this t85 project. It wakes and immediately goes back to sleep if the thermistor has not changed value... The value persists thru the sleep. Same idea with photocel, I should think.
The trick w/ battery power is to sleep much longer than you are awake unless there is work to do. It is not absolutely necessary to use an interrupt to awake if you go back to sleep quickly.