Gemma startup time

For other supported Arduino products from Adafruit: Shields, accessories, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
User avatar
pmidthun
 
Posts: 10
Joined: Fri Jul 24, 2015 10:23 am

Re: Gemma startup time

Post by pmidthun »

Hello,

Before I try, I want to ask, is it possible to do this with a hall sensor providing the interrupt signal to bring the gemma out of sleep? I am concerned because I believe the hall sensor needs power to work... The hall sensor is powered from vout on the gemma.

I have a sealed flashlight-like device running neopixels and I use a hall sensor as a switch to rotate through different patterns/programs/functions by having each function call another function named checkswitch() and returning if necessary.

void loop() {
off();
rainbow(20);
theaterChaseRainbow(90);
greenlight();
rainbowCycle(10);
theaterChase2();
colorWipe2();
}

The function off() tries to turn as much off as possible while still reading the hall sensor using checkswitch() function:

void off() {
for (int i=0; i < 16; i++){
strip.setPixelColor(i, 0, 0, 0);
}
strip.show();
while(1){
if (checkswitch() == 1) {
return; }
else {delay(1000);}
}
}

Here is the checkswitch() function reading the hall sensor on pin 0. I know I would need to change the pin.

int checkswitch(){
int a = digitalRead(0);
if(a==LOW) {
return 1;}
else {return 0;}
}

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: Gemma startup time

Post by adafruit_support_mike »

You can use a pin-change interrupt to respond to input without actually having to process anything. This project does something similar:

https://learn.adafruit.com/trinket-slas ... t/overview

If the microcontroller is asleep but configured to respond to external interrupts, it has to wake up and start running again if such an interrupt occurs. If all you want to do is wake the chip up, that's already done by the time the chip begins to process the interrupt handler. It can return immediately and you'll still get the behavior you want.

User avatar
LXF
 
Posts: 20
Joined: Wed Jan 14, 2015 12:07 pm

Re: Gemma startup time

Post by LXF »

adafruit_support_mike wrote:Yeah, you should be able to switch the VCC line with a PNP transistor. The circuit would be pretty much the same as the one above, but with the transistor's emitter and the 10k resistor connected to VCC instead of GND.

For 25 NeoPixels, you'll probably want a PNP transistor that can handle an amp of current or more. I happen to use the SS8550, which can do up to 1.5A:
https://www.digikey.com/product-detail/ ... ND/1047357
Hi Mike,
I think I should send you and the others a note.
Actually I fixed the issue with help of a friend who is much more experienced than me..
I am now down to 0.2 mA - all fine. I used the NPN and your circuit.
What I did additionally is to set the data pin as input when the Attiny goes to sleep - voila.

Here is the sleep code

Code: Select all

void goSleep(){
digitalWrite(PowerOffPin,LOW);
pinMode(1,INPUT); 
GIMSK = _BV(PCIE);     // Enable pin change interrupt
power_all_disable();   // All peripherals off
set_sleep_mode(SLEEP_MODE_PWR_DOWN);
sleep_enable();
sei();                 // Keep interrupts disabled
sleep_mode();          // Power down CPU (pin 1 will wake)
// Execution resumes here on wake.
GIMSK = 0;             // Disable pin change interrupt
power_timer0_enable(); // Re-enable timer
power_usi_enable();    // Re-enable USI
pinMode(1,OUTPUT); 
digitalWrite(PowerOffPin,HIGH);
idletime = millis();  //need to reset the timer, otherwise it will immeadeatly go beack to sleep again
}

Thanks a lot, problem solved.

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: Gemma startup time

Post by adafruit_support_mike »

Glad to hear you got it working. Happy hacking!

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Arduino products from Adafruit”