const int redPin = D0; const int analogPin = A1; const int yellowPin = D2; const int greenPin = D3; const int greenPin = D3; const int timedelay = 1; #define BUFFER_SIZE 60 int buffer[BUFFER_SIZE]; int bufferIndex = 0; int sum = 0; float mean = 0; float stdDev = 0; int threshold = 1000; void setup() { Serial.begin(9600); pinMode(redPin, OUTPUT); pinMode(analogPin, INPUT); pinMode(yellowPin, OUTPUT); pinMode(greenPin, OUTPUT); memset(buffer, 0, sizeof(buffer)); } void loop() { int analogValue = analogRead(analogPin); Serial.println(analogValue); Serial.prinln(threshold); if (Serial.available() > 0) { int newThreshold = Serial.parseInt(); if (newThreshold > 0) { threshold = newThreshold; } } int threshold = 1000; int timedelay = 100; if (abs(analogValue - 1750) > threshold) { digitalWrite(redPin, HIGH); delay(timedelay); digitalWrite(redPin, LOW); } else if (abs(analogValue - 1750) > threshold) { digitalWrite(yellowPin, HIGH); delay(timedelay); digitalWrite(yellowPin, LOW); } else if (abs(analogValue - 1750) > threshold) { digitalWrite(greenPin, HIGH); delay(timedelay); digitalWrite(greenPin, LOW); } }