/* Adafruit Arduino - strandtest Modified by Salama for Fab Academy 2018, Final Project. changed color code and add sensor code and serial commnunication */ #include //serial commincation library #include //Neopixel library #ifdef __AVR__ #include #endif #define PIN 8 // Neopixel connected to pin 8 Adafruit_NeoPixel strip = Adafruit_NeoPixel(9, PIN, NEO_GRB + NEO_KHZ800); SoftwareSerial myserial(0,1); //Rx,Tx int smoke = 7; // sensor in pin 7 int desire = 150; // at this value the colors will change int sensor = 0; // takes the data from sensor void setup() { pinMode(smoke,INPUT); // sensor pin 7 is input strip.begin(); strip.show(); myserial.begin(9600); // set up Serial library at 9600 bps } void loop() // run over and over again { sensor = analogRead(smoke); //take the readings from sensor //Serial.println(sensor); delay(50); if (sensor > desire){ // if the sensor data is more than 150 colorWipe(strip.Color(255, 0, 0), 50); // Red myserial.print("z"); //send z to serial } else { colorWipe(strip.Color(0, 0, 0), 50); // LED off myserial.print("good"); // send good to serial } } void colorWipe(uint32_t c, uint8_t wait) { for(uint16_t i=0; i