phototransistor minor issue

I just purchased a photo-transistor from Adafruit. Here a link Photo Transistor Light Sensor : ID 2831 : $0.95 : Adafruit Industries, Unique & fun DIY electronics and kits. It is sensor to the light. I am trying to figure it out it only able to recognize the analogWrite function and it's very sensitive responding but it does not recognize when I change to digitalWrite. How come digitalWrite did not respond well compare to the analogWrite because I am working on the interrupt in 2 and 3 pin UNO to wake up.

I really need to put sleep forever until the open the dark room to trigger full power light on once I open the dark room door.

any advice please...

Show us a photo or drawing of how the device is connected. Show us the code that you are using.

Consider using a 5V solar panel, with a 10K resistor in series, as the sensor. It doesn't take any power to run (as does a phototransistor), and produces enough voltage to trigger a wakeup signal.

Or, the solar panel could simply power the Arduino.

The diagram I created on Fritzing. I assume that the digitalRead serial print only numbers are "1" and "0" not the same as when I changed to the analogWrite it responds to different numbers from 0 to 1023 range obviously. The overall components are working perfectly, but when I am trying to add the LowPower library. I am struggling with code.

I would like to know if the light is on to wake up the Arduino microprocessor to do work before returning to sleep once I turn the light off.

I am kind of confused which one I should put into the line detachInterruput(...).

here the code

Please help thanks


The second attachInterrupt() cancels the first and anyway you don’t use an interrupt to put it to sleep, only to wake it. attachInterrupt() goes in setup(). You don’t detach it afterwards.
You enter sleep mode when you read the digital pin and determine that it is dark.

However, before you even start using interrupts, the first thing to do is a very simple sketch which, in the loop(), reads (digitalRead) the pin which the photo transistor is connected to and switches a led on when it detects light and off when dark.

Thank you for tips! That is really helpful.
Hmm that's interesting because when I am using the attachInterrupt methods changed to the set up function of the mode RISING that trigger when the pin goes from the LOW to HIGH, so Arduino can do really hard working the whole components whenever I turn light off and it able to force Arduino sleep and I have successfully the output serial monitor is stopping function. I assume that the Arduino is reducing the consumption battery very well. Please critical me if I am wrong thanks.

When an Arduino is sleeping, the current consumption can be as low as a few micro amps.
However, that also depends on what else is in the circuit and which Arduino you use. A raw ATmega328p is good, but other such as the Nano which have components like power on leds, voltage regulators, usb chips etc. making very low power consumption impossible to achieve.

Should I concern that making very low power consumption impossible to achieve during sleep mode?

What happen if I am using the 8 D of alkaline batteries (total voltages is 12) external linear voltage dropped to 5 voltages output into the Arduino Nano's Vin, old boot-loader of ATmega328p, to stay power on during the sleep mode. Would this reduce power consumption or not?

Would you recommend me to replace microprocessor to Arduino Pro Mini? Because I discovered that on website Sparkfun it states that , "we can reduce the supply current from 15mA, down to just 4mA"

You do not apply 5V to Vin. The on board 5V regulator requires a minimum voltage of 7V to properly regulate. Connect 5V to the 5V input.

The Pro Mini does away with some of the power users of the Nano. The USB-TTL converter for one. So you will need a FTDI or programmer to upload code.

Using a linear voltage regulator with batteries may not be optimal. To drop 12V to 5V is a 7V drop. Multiply that 7V by the current drawn and you will see the power that is lost as heat. A switch mode buck converter would be much more efficient.