/* AnalogReadSerial Reads an analog input on pin A0, prints the result to the serial monitor. Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground. created 09/22 2015 by Amalie Secher Rusbjerg */ int numberObject1 = 0; int numberObject2 = 0; int numberObject3 = 0; // the setup routine runs once when you press reset: void setup() { // initialize serial communication at 9600 bits per second: Serial.begin(9600); // initialize digital pin 13 as an output. pinMode(13, OUTPUT); } // the loop routine runs over and over again forever: void loop() { // read the input on analog pin A0: int sensorValue = analogRead(A0); sensorValue = map(sensorValue, 0, 1023, 1, 3); // print out the value you read: delay(500); // delay in between reads for stability switch (sensorValue) { case 1: Serial.println("Object 1"); digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(13, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second numberObject1++; Serial.println(numberObject1); //LED flash 1 time when varlue equals 1 break; case 2: Serial.println("Object 2"); digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level) delay(500); // wait for haf a second digitalWrite(13, LOW); // turn the LED off by making the voltage LOW delay(500); // wait for haf a second digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level) delay(500); // wait for haf a second digitalWrite(13, LOW); // turn the LED off by making the voltage LOW delay(500); // wait for haf a second numberObject2++; Serial.println(numberObject2); //LED flash 2 times when varlue equals 2 break; case 3: Serial.println("Object 3"); digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level) delay(100); // wait for 100 m second digitalWrite(13, LOW); // turn the LED off by making the voltage LOW delay(100); // wait for 100 m second digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level) delay(100); // wait for 100 m second digitalWrite(13, LOW); // turn the LED off by making the voltage LOW delay(100); // wait for 100 m second digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level) delay(100); // wait for 100 m second digitalWrite(13, LOW); // turn the LED off by making the voltage LOW delay(100); // wait for 100 m second numberObject3++; Serial.println(numberObject3); //LED flash 3 times when varlue equals 3 break; default: // if nothing else matches, do the default // default is optional break; } }