Show Posts
Pages: 1 2 [3] 4 5 ... 39
31  Using Arduino / Project Guidance / Re: Nicks low power code, modifying for two push buttons on: December 23, 2013, 09:14:37 pm
Thanks, I never seem to stop the simple oversights!

It seems to be working now, but I'm getting strange behavior - the LED on D13 - D2 triggered is flashing at the expected rate, but the LED on D12 - D3 triggered is flashing at around twice the expected rate?
32  Using Arduino / Project Guidance / Re: Nicks low power code, modifying for two push buttons on: December 23, 2013, 07:56:52 pm
Thanks Nick! I can kind of follow that but I can't get the code working,  D12 is always flashing? Not sure what I am doing wrong?

Thanks

Code:
#include <avr/sleep.h>

const byte LEDA = 13;
const byte LEDB = 12;
 
volatile byte wakeUpPin;

void combinedWake ()
{
  // cancel sleep as a precaution
  sleep_disable();
  // must do this as the pin will probably stay low for a while
  detachInterrupt (0);
}  // end of combinedWake

void wake_A ()
{
wakeUpPin = 2;
combinedWake ();
}  // end of wake_A

void wake_B ()
{
wakeUpPin = 3;
combinedWake ();
}  // end of wake_B

void setup ()
  {
  digitalWrite (2, HIGH);  // enable pull-up
  }  // end of setup

void loop ()
{
  if (wakeUpPin == 2)
  {
  pinMode (LEDA, OUTPUT);
  digitalWrite (LEDA, HIGH);
  delay (50);
  digitalWrite (LEDA, LOW);
  delay (50);
  pinMode (LEDA, INPUT);
  }
 
else if (wakeUpPin == 3)
{
  pinMode (LEDB, OUTPUT);
  digitalWrite (LEDB, HIGH);
  delay (50);
  digitalWrite (LEDB, LOW);
  delay (50);
  pinMode (LEDB, INPUT);
}
 

  // disable ADC
  ADCSRA = 0; 
 
  set_sleep_mode (SLEEP_MODE_PWR_DOWN); 
  sleep_enable();

  // Do not interrupt before we go to sleep, or the
  // ISR will detach interrupts and we won't wake.
  noInterrupts ();
 
// will be called when pin D2 goes low 
  attachInterrupt (0, wake_A, LOW);
// will be called when pin D3 goes low 
  attachInterrupt (1, wake_B, LOW);
 
 
 
 
  // turn off brown-out enable in software
  // BODS must be set to one and BODSE must be set to zero within four clock cycles
  MCUCR = bit (BODS) | bit (BODSE);
  // The BODS bit is automatically cleared after three clock cycles
  MCUCR = bit (BODS);
 
  // We are guaranteed that the sleep_cpu call will be done
  // as the processor executes the next instruction after
  // interrupts are turned on.
  interrupts ();  // one cycle
  sleep_cpu ();   // one cycle


  } // end of loop
33  Using Arduino / Project Guidance / Re: Nicks low power code, modifying for two push buttons on: December 23, 2013, 03:35:03 pm
Hi Nick, many thanks for the great resources!

What is the variable that it sets?

34  Using Arduino / Project Guidance / Re: Nicks low power code, modifying for two push buttons on: December 23, 2013, 01:09:05 pm
Hmmm I'm not sure how one one would use diodes? Is it not possible to decide which interupt has been triggered and run a routine based on that?

Thanks smiley
35  Using Arduino / Project Guidance / Nicks low power code, modifying for two push buttons on: December 23, 2013, 07:14:27 am
Hi all, I would like to modify Nick Gammons' power saving code to have two buttons (on interrupt pins). In the current code it seems that if the processor wakes up it runs the whole loop function, but I would like it to run a prefined function on one button input and another on the second button input?

Thanks

Code:
#include <avr/sleep.h>

const byte LED = 9;
 
void wake ()
{
  // cancel sleep as a precaution
  sleep_disable();
  // must do this as the pin will probably stay low for a while
  detachInterrupt (0);
}  // end of wake

void setup ()
  {
  digitalWrite (2, HIGH);  // enable pull-up
  }  // end of setup

void loop ()
{
 
  pinMode (LED, OUTPUT);
  digitalWrite (LED, HIGH);
  delay (50);
  digitalWrite (LED, LOW);
  delay (50);
  pinMode (LED, INPUT);
 
  // disable ADC
  ADCSRA = 0; 
 
  set_sleep_mode (SLEEP_MODE_PWR_DOWN); 
  sleep_enable();

  // Do not interrupt before we go to sleep, or the
  // ISR will detach interrupts and we won't wake.
  noInterrupts ();
 
  // will be called when pin D2 goes low 
  attachInterrupt (0, wake, LOW);
 
  // turn off brown-out enable in software
  // BODS must be set to one and BODSE must be set to zero within four clock cycles
  MCUCR = bit (BODS) | bit (BODSE);
  // The BODS bit is automatically cleared after three clock cycles
  MCUCR = bit (BODS);
 
  // We are guaranteed that the sleep_cpu call will be done
  // as the processor executes the next instruction after
  // interrupts are turned on.
  interrupts ();  // one cycle
  sleep_cpu ();   // one cycle

  } // end of loop
36  Using Arduino / Project Guidance / Re: IR remote controller project with low power? on: December 18, 2013, 06:40:04 am
I need to think a bit more about it I guess, it would be nice to only have to press one button but maybe could use come dual pole switches - one pole to wake up via interrupt and the other pole to be read as a digital input?

Thanks
37  Using Arduino / Project Guidance / Re: IR remote controller project with low power? on: December 06, 2013, 09:53:46 pm
the only trouble with that though is I would need to press two buttons, one hardware interupt then another button connected to a standard digital IO pin?

Thanks
38  Using Arduino / Project Guidance / Re: IR remote controller project with low power? on: December 04, 2013, 07:36:43 am
any ideas?
39  Using Arduino / LEDs and Multiplexing / Re: WS2801, Fast SPI or Adafruit library? on: December 02, 2013, 05:16:35 pm
True  smiley-razz

Just wondering if there is any advantage in one over the other? I guess the fast spi library might be faster and able to drive more pixels?

Thanks
40  Using Arduino / LEDs and Multiplexing / WS2801, Fast SPI or Adafruit library? on: December 02, 2013, 12:34:38 pm
Hi all, I have a string of WS2801 LEDs that I would now like to use. I have tested them with the Adafruit library before and they worked well, but a few days ago I came across the Fast SPI library which appears to be compatible with WS2801 drivers.

I'm now wondering if I would be better off wiring the string to the SPI pins of the Arduino pro mini that I planned to use or just stick to the Adafruit method?
41  Using Arduino / Microcontrollers / Re: low power consumption 328p on: December 02, 2013, 06:15:47 am
Thanks guys. That is true if it is sleeping I guess 16MHz will be fine.

Probably a silly question but running at 8MHz, will the whole sketch run half speed - IE. delay(100) would become delay(200)?

Thanks
42  Using Arduino / Microcontrollers / low power consumption 328p on: November 30, 2013, 09:44:07 pm
Hi all. I would like to run an 328P at low power, will it be OK running from 3x AA batteries? At what voltage is it likely to stop running?

If I used the internal 8MHz clock, would that improve consumption much? I want to make a IR remote control, will running at 8Mhz screw the sketch up - timings etc?

Thanks
43  Using Arduino / Project Guidance / Re: IR remote controller project with low power? on: November 29, 2013, 07:15:53 am
Thanks guys, I will have a read of the link later.

If I was to use interrupts, how could I read multiple inputs?
44  Using Arduino / Project Guidance / IR remote controller project with low power? on: November 28, 2013, 07:14:46 pm
Hi all. I would like to make a IR remote controller and run it off batteries - maybe 2 AA cells? The IR part should be fine, but I'm not sure about how to achieve the lowest power consumption possible. I will be using a 328P - because I have a few around the place and also I will probably use most of the digital inputs to read buttons. This means that 99% of the time the 328 would be idle, but always checking pin state changes.

Any advice would be gratefully received smiley
45  Community / Exhibition / Gallery / Re: GPS time-date on: November 28, 2013, 08:12:47 am
great idea, thanks for sharing
Pages: 1 2 [3] 4 5 ... 39