#include #define PIN 6 //Pin to which the DIN for the first pod is connected const int numReadings = 5; int reading; // the readings from the analog input int index = 0; // the index of the current reading int total = 0; // the running total int average = 0; // the average int podTrigger = 0; char sensorPins[6] = {A5,A4,A3,A2,A1,A0}; //Sensor pins int sensorValues[6] = {0,0,0,0,0,0}; int calibratedsensorValues[6] = {0,0,0,0,0,0}; char podColours[6][3] = {{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0}}; char podLeds[6][6] = {{0,1,2,3,4,5},{6,7,8,9,10,11},{12,13,14,15,16,17},{18,19,20,21,22,23},{24,25,26,27,28,29},{30,31,32,33,34,35}}; //Array in which the seperate led's are defined with regard to the pod they are part of int podTriggered[6] = {0,0,0,0,0,0}; //Array for storing which pods have cups on them Adafruit_NeoPixel strip = Adafruit_NeoPixel(36, PIN, NEO_GRB + NEO_KHZ800); void setup() { strip.begin(); //Initialises the led's strip.show(); Serial.begin(9600); //For debugging purposes } void loop() { updateSensors(); updatePodColours(); ///////// Default neopixel functions to be used in futhur expansion ////// /* colorWipe(strip.Color(255, 0, 0), 50); // Red colorWipe(strip.Color(0, 255, 0), 50); // Green colorWipe(strip.Color(0, 0, 255), 50); // Blue // Send a theater pixel chase in... theaterChase(strip.Color(127, 127, 127), 50); // White theaterChase(strip.Color(127, 0, 0), 50); // Red theaterChase(strip.Color(0, 0, 127), 50); // Blue rainbow(20); rainbowCycle(20); theaterChaseRainbow(50); */ } //////////////Read Sensors and POD update //////////// void updateSensors(){ // Reads sensor values and stores themin the array to be used later for( int i = 0; i<6;i++){ average = 0; total =0; for ( int k = 0; k974){ // Sensor threshold for the different pods cahmphered 968 square 974 use the serial debugging to tune the threshold to our spesific setup if(podTriggered[i] == 0){ // Checks if the pod has been triggered previously or not podTriggered[i] = 1; podTrigger++; podColours[i][0] = 000; //Sets the colours for the triggered pod podColours[i][1] = 000; podColours[i][2] = 255; for(int j = 0; j<6 ; j++){ //Updates and displays the pods colours strip.setPixelColor(podLeds[i][j], strip.Color(podColours[i][0],podColours[i][1],podColours[i][2])); strip.show(); } } } else{ podTriggered[i] = 0; podColours[i][0] = 255; podColours[i][1] = 000; podColours[i][2] = 000; for(int j = 0; j<6 ; j++){ strip.setPixelColor(podLeds[i][j], strip.Color(podColours[i][0],podColours[i][1],podColours[i][2])); strip.show(); } } } } ////////////// Extra default neopixel POD FUNCTIONS for use in furthur expansion ////////////////// // Fill the dots one after the other with a color void colorWipe(uint32_t c, uint8_t wait) { for(uint16_t i=0; i