/* Adafruit Arduino - strandtest Modified by Salama for Fab Academy 2018, Final Project. changed color code and add sensor code. Modified by Zahrah Al-Yahyaee for Fab Academy 2018, Final Project. Changed color and sensor code. */ // library for serial communication #include //this is the library for NEOPixel #include #define PIN 8 // Define the pin for NEOPixel, NEOpixel can be programed with port B only for attiny 44 and 84 // Parameter 1 = number of pixels in strip, neopixel stick has 8 // Parameter 2 = pin number (most are valid) // Parameter 3 = pixel type flags, add together as needed: // NEO_RGB Pixels are wired for RGB bitstream // NEO_GRB Pixels are wired for GRB bitstream, correct for neopixel stick // NEO_KHZ400 400 KHz bitstream (e.g. FLORA pixels) // NEO_KHZ800 800 KHz bitstream (e.g. High Density LED strip), correct for neopixel stick Adafruit_NeoPixel strip = Adafruit_NeoPixel(20, PIN, NEO_GRB + NEO_KHZ800); // int light = 7; //Define the sensor pin int desire = 1000; //Define at what level the LEDs will change int sensor = 0; //Initialize the sensor reading from 0 SoftwareSerial myserial(0,1); void setup() { pinMode(light,INPUT); // initialize the sensor pin as an input. strip.begin(); strip.show(); // Initialize all pixels to 'off' myserial.begin(9600); // set up Serial library at 9600 bps Serial.begin(9600); // set up Serial library at 9600 bps } void loop() // run over and over again { sensor = analogRead(light); Serial.println(sensor); delay(10); if (sensor > desire){ // check if state changed rainbowCycle(2); // myserial.println(sensor); // colorWipe(strip.Color(0, 0, 255), 20); // no light } else { colorWipe(strip.Color(255, 255, 255), 20); // no light // myserial.println(sensor); } } void colorWipe(uint32_t c, uint8_t wait) { for(uint16_t i=0; i