#define potPin A4
#define buttonPin 3
#define redLedPin 12
#define blueLedPin 11
void setup() {
// put your setup code here, to run once:
pinMode(potPin, INPUT);
pinMode(buttonPin, INPUT_PULLUP);
pinMode(redLedPin, OUTPUT);
pinMode(blueLedPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
static int potVals[200];
static int potValsI = 0;
long sumVal = 0;
potVals[potValsI] = analogRead(potPin);
potValsI ++;
if (potValsI >= 200) {
for (int i=0;i<200;i++) {
if (potVals[i] > 500) {
Serial.println(potVals[i]);
}
sumVal = sumVal + potVals[i];
potVals[i] = 0;
}
potValsI = 0;
Serial.print("Sum: ");
Serial.println(sumVal);
delay(1000);
}
}