Trouble getting attiny84 to wake from sleep and animate addressable led

Hi there. I am trying to create a circuit using an attiny84 which sleeps until a button is pressed and then it animates an addressable led. I have managed to get the tiny to sleep and ive managed to get it to animate the led but i have only been able to use physical pin 5, (arduino pin 8) to get either of them to work which leaves me in a predicament. i have plenty of pins left as you can see so its frustrating that i have only had success using this pin to do either of the tasks. is there any way i could either wake the tiny or animate the led with another pin? ive included a schematic for reference.

i have been using this library to put the tiny to sleep.

i have been using the neopixel library to animate the led.

here is the sleep code:

/** This example shows you how to wake from an external interrupt rather than waiting for a given length of time.
 * 
 * Connect a button betwen the interrupt pin and ground, press said button to trigger an interrupt and wake.
 * 
 */

#include <SimpleSleep.h>
SimpleSleep Sleep;

const uint8_t ledPin = 5;
const uint8_t interruptPin = 8;

void setup()
{
  pinMode(ledPin, OUTPUT);
  pinMode(interruptPin, INPUT_PULLUP);
  attachInterrupt(digitalPinToInterrupt(interruptPin), interruptHandler, LOW);
}

void interruptHandler()
{
  // In this example, do nothing we will just wakeup and continue from where-ever
  // we went to sleep, of course maybe you might want to do something else on
  // the interrupt also, up to you.
}

void loop()
{
  // Blink once then sleep until an external interrupt happens
  digitalWrite(ledPin, HIGH); 
  delay(500);
  digitalWrite(ledPin, LOW);
  delay(500);
  digitalWrite(ledPin, HIGH); 
  delay(500);
  digitalWrite(ledPin, LOW);

  Sleep.deeply();
}

here is the led code:


#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
 #include <avr/power.h> // Required for 16 MHz Adafruit Trinket
#endif


#define LED_PIN    8

// How many NeoPixels are attached to the Arduino?
#define LED_COUNT 6

// Declare our NeoPixel strip object:
Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);



// setup() function -- runs once at startup --------------------------------

void setup() {
  

  strip.begin();           // INITIALIZE NeoPixel strip object (REQUIRED)
  strip.show();            // Turn OFF all pixels ASAP
  strip.setBrightness(50); // Set BRIGHTNESS to about 1/5 (max = 255)
}


// loop() function -- runs repeatedly as long as board is on ---------------

void loop() {
  // Fill along the length of the strip in various colors...
  colorWipe(strip.Color(255,   0,   0), 50); // Red
  colorWipe(strip.Color(  0, 255,   0), 50); // Green
  colorWipe(strip.Color(  0,   0, 255), 50); // Blue

  // Do a theater marquee effect in various colors...
  theaterChase(strip.Color(127, 127, 127), 50); // White, half brightness
  theaterChase(strip.Color(127,   0,   0), 50); // Red, half brightness
  theaterChase(strip.Color(  0,   0, 127), 50); // Blue, half brightness

  rainbow(10);             // Flowing rainbow cycle along the whole strip
  theaterChaseRainbow(50); // Rainbow-enhanced theaterChase variant
}

Show us your code with the two functions combined…

Where is your push button on the schematic ?

I've not yet combined them because I tested each function independently first and saw that i could only use pin 5. Ive not added in the led or pushbutton to the schematic because none of them are permanent yet. when i am running the sleep code i wake the tiny by grounding pin 5. when i am running the led code i connect the data in pin of the led to pin 5.

Ok ive managed to change the interrupt pin by using this function: attachPCINT(digitalPinToPCINT(interruptPin), interruptHandler, LOW);
so that seems to have solved the issue which is nice!
Would still be interested to know whether its possible to run addressable leds from other pins...
here is the full combined code:


#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
 #include <avr/power.h> // Required for 16 MHz Adafruit Trinket
#endif

#define LED_PIN    8

// How many NeoPixels are attached to the Arduino?
#define LED_COUNT 6

// Declare our NeoPixel strip object:
Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);



 #include "PinChangeInterrupt.h"


#include <SimpleSleep.h>
SimpleSleep Sleep;


const uint8_t interruptPin = 0;

void setup()
{
  pinMode(ledPin, OUTPUT);
  pinMode(interruptPin, INPUT_PULLUP);

  attachPCINT(digitalPinToPCINT(interruptPin), interruptHandler, LOW);


  strip.begin();           // INITIALIZE NeoPixel strip object (REQUIRED)
  strip.show();            // Turn OFF all pixels ASAP
  strip.setBrightness(100); // Set BRIGHTNESS to about 1/5 (max = 255)

}

void interruptHandler()
{
  // In this example, do nothing we will just wakeup and continue from where-ever
  // we went to sleep, of course maybe you might want to do something else on
  // the interrupt also, up to you.
}

void loop()
{
  rainbow(10);
  pixelsOff();  

  Sleep.deeply();
}


void pixelsOff(){
  for(int i = 0; i < strip.numPixels(); i++){
    strip.setPixelColor(i,0,0,0);
  }
  strip.show();
}

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.