Skip to content

Instantly share code, notes, and snippets.

@rjcorwin
Created December 8, 2012 00:27
Show Gist options
  • Save rjcorwin/4237798 to your computer and use it in GitHub Desktop.
Save rjcorwin/4237798 to your computer and use it in GitHub Desktop.
(by robrock) arduino code that will get electronic flame weeder ignition/electronic LP solenoid on/off sparking when the temperature measured by the thermocouple falls beneath a set threshold
const int numReadings = 10;
int readings[numReadings];
int index = 0;
int total = 0;
int average = 0;
int led = 9;
int inputPin = A0;
void setup()
{
Serial.begin(9600);
for (int thisReading = 0; thisReading < numReadings; thisReading++)
readings[thisReading] = 0;
}
void loop() {
total= total - readings[index];
readings[index] = analogRead(inputPin);
total= total + readings[index];
index = index + 1;
if (index >= numReadings)
index = 0;
average = total / numReadings;
Serial.println(average);
delay(1);
if (average > 30) {
digitalWrite (led, LOW);
}
else if (average < 30) {
digitalWrite(led, HIGH);
delay(100);
digitalWrite(led, LOW);
delay(100);
digitalWrite(led, HIGH);
delay(100);
digitalWrite(led, LOW);
delay(100);
digitalWrite(led, HIGH);
delay(100);
digitalWrite(led, LOW);
delay(1000);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment