Commit beefbb23 authored by Sam Guyer's avatar Sam Guyer
Browse files

Mods

parent 8d8b8171
#include <SPI.h>
#include <Wire.h>
#include <FastLED.h>
......@@ -6,16 +7,19 @@
#include <RTC_DS3231.h>
#include <Adafruit_LEDBackpack.h>
#include <Adafruit_GFX.h>
#include <SparkFun_APDS9960.h>
Adafruit_7segment matrix = Adafruit_7segment();
SparkFun_APDS9960 apds = SparkFun_APDS9960();
// -----------------------------------------
// LED strip
#define LED_PIN 6
// -- Number of LEDs in the strip
#define NUM_LEDS 60
#define NUM_LEDS 72
// -- LED elements
CRGB leds[NUM_LEDS];
......@@ -50,8 +54,20 @@ void setup()
// -- Initialize the soft-pot (pull-up resistor)
digitalWrite(SOFTPOT_PIN, HIGH);
// -- Initialize the photo resister
// -- Initialize the gesture sensor
// Initialize APDS-9960 (configure I2C and initial values)
if ( apds.init() ) {
Serial.println(F("APDS-9960 initialization complete"));
} else {
Serial.println(F("Something went wrong during APDS-9960 init!"));
}
// Start running the APDS-9960 light sensor (no interrupts)
if ( apds.enableLightSensor(false) ) {
Serial.println(F("Light sensor is now running"));
} else {
Serial.println(F("Something went wrong during light sensor init!"));
}
// -- Create the LED entries
FastLED.addLeds<WS2812, LED_PIN, GRB>(leds, NUM_LEDS);
......@@ -61,9 +77,9 @@ void setup()
// -- Set the date and time, if necessary
DateTime now = RTC.now();
DateTime compiled = DateTime(__DATE__, __TIME__);
if (now.unixtime() < compiled.unixtime()) {
//if (now.unixtime() < compiled.unixtime()) {
RTC.adjust(DateTime(__DATE__, __TIME__));
}
//}
// -- Seed the random number generator
randomSeed(now.unixtime());
......@@ -114,27 +130,30 @@ void loop()
}
// -- Show the time on the LED strip
for (int i = 0; i < NUM_LEDS; i++) {
for (int i = 0; i < 60; i++) {
leds[i] = CRGB::Black;
if (i < now.minute()) {
CRGB flame(180, 130, 40);
leds[i] = flame;
}
if ((i%5 == 0) && ((i/5) < hour)) {
leds[i] = CRGB::Blue;
}
if (i == now.second()) {
leds[i] = CRGB::Red;
}
}
for (int i = 0; i < 12; i++) {
int index = i + 60;
if (i < hour)
leds[index] = CRGB::Blue;
else
leds[index] = CRGB::Black;
}
// -- Set the brightness according to the ambient light
int photo = analogRead(PHOTORESISTOR_PIN);
int ledbrightness = map(photo, 300, 1023, 0, MAX_BRIGHTNESS);
int ledbrightness = map(photo, 0, 1023, 0, MAX_BRIGHTNESS);
FastLED.setBrightness(ledbrightness);
int digbrightness = map(photo, 300, 1023, 0, 15);
matrix.setBrightness(digbrightness);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment