#include <Adafruit_NeoPixel.h>
#define LIGHT_SENSOR A5
#define TEMP_SENSOR A0
#define TOGGLE_SWITCH 21
#define BUTTON_A 4
#define BUTTON_B 19
#define BUZZER 5
//10 leds on pin 17
Adafruit_NeoPixel leds(10,17, NEO_GRB + NEO_KHZ800);
int counter = 0;
void setup()
{
Serial.begin(9600);
leds.begin();
leds.show();
leds.setBrightness(50);
pinMode(BUZZER, OUTPUT);
pinMode(BUTTON_A, INPUT_PULLUP);
pinMode(BUTTON_B, INPUT_PULLUP);
pinMode(LIGHT_SENSOR, INPUT);
pinMode(TEMP_SENSOR, INPUT);
pinMode(TOGGLE_SWITCH, INPUT);
}
void loop()
{
//for each colour of the rainbow ( Look at the original Neopixel example)
for (long first = 0; first < 5*65536; first += 256)
{
//set every pixel to be a portion of the rainbow
for (int i = 0; i < leds.numPixels(); i++)
leds.setPixelColor(i, leds.gamma32(leds.ColorHSV(first + (i * 6553L))));
leds.show(); // Update leds with new contents
if (counter > 10){
Serial.print("Temperature Reading: ");
Serial.println(analogRead(TEMP_SENSOR));
Serial.print("Light Reading:");
Serial.println(analogRead(LIGHT_SENSOR));
Serial.print("Button Status: ");
Serial.print(digitalRead(BUTTON_B) ?"[B] " :"");
Serial.print(digitalRead(BUTTON_A) ?"[A] " :"");
Serial.print("Switch: [");
Serial.print(digitalRead(TOGGLE_SWITCH) ?"HIGH" :"LOW");
Serial.println("]");
Serial.println("------------------------------------");
counter = 0;
}else {
counter++;
}
delay(10);
}
for (int i =0; i < 10; i++) {
tone(BUZZER, 200 +(40 * i));
delay(100);
}
noTone(BUZZER);
}