Exemplo n.º 1
0
Arquivo: Lily.cpp Projeto: Valoa/lily
 #include "Lily.h"
#include <avr/sleep.h> // For sleeping.
#include <avr/power.h> // For sleeping.
#include <avr/wdt.h> // For sleeping.
#include <Adafruit_DotStar.h>

//Led stuff
#define NUMPIXELS 3
#define DATAPIN    4
#define CLOCKPIN   3
Adafruit_DotStar strip = Adafruit_DotStar(NUMPIXELS, DATAPIN, CLOCKPIN, DOTSTAR_BGR);






///////////////////////////////////////////Battery Stuff///////////////////////////////////////////

long readVcc() { // read batt level
  long result;    // Todo: does this work together with reading the LDR on A5 or is more setup needed?
  ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);    // Read 1.1V reference against AVcc
  delay(128); // Wait for Vref to settle
  ADCSRA |= _BV(ADSC); // Convert
  while (bit_is_set(ADCSRA, ADSC));
  result = ADCL;
  result |= ADCH << 8;
  result = 1126400L / result; // Back-calculate AVcc in mV
  return result;
}
Exemplo n.º 2
0
// e.g. Adafruit_DotStar(NUMPIXELS, DOTSTAR_RGB);
// e.g. Adafruit_DotStar(NUMPIXELS, DATAPIN, CLOCKPIN, DOTSTAR_RGB);
//
// DOTSTAR_RGB
// DOTSTAR_RBG
// DOTSTAR_GRB
// DOTSTAR_GBR (default)
// DOTSTAR_BRG
// DOTSTAR_BGR

//-------------------------------------------------------------------
// Here's how to control the LEDs from any two pins (Software SPI):
//-------------------------------------------------------------------
#define DATAPIN   D4
#define CLOCKPIN  D5
Adafruit_DotStar strip = Adafruit_DotStar(NUMPIXELS, DATAPIN, CLOCKPIN);

//-------------------------------------------------------------------
// Here's how to control the LEDs from any two pins (Hardware SPI):
//-------------------------------------------------------------------
// Hardware SPI is a little faster, but must be wired to specific pins
// (Spark Core = pin A5 for data, A3 for clock)
//Adafruit_DotStar strip = Adafruit_DotStar(NUMPIXELS);

void setup() {
    strip.begin(); // Initialize pins for output
    strip.show();  // Turn all LEDs off ASAP
}

// Runs 10 LEDs at a time along strip, cycling through red, green and blue.
// This requires about 200 mA for all the 'on' pixels + 1 mA per 'off' pixel.