Here is the code for temperature sensing phase control.
bool state=LOW;
int pin=10;// this pin connects to zero crossing detector circuit
int v=540; // sets low at start of program until analog read at 1 minute
int vin = 2; // this is the analog read pin
int us=12396; // sets phase control turn on points
int ledPin = 11; // pin 8 connects to random phase opto
unsigned long previousMillis=0;
const long interval = 15000;
void setup() {
Serial.begin(9600);
pinMode(pin,INPUT);
pinMode(ledPin, OUTPUT);}
void loop() {
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= interval) {
previousMillis = currentMillis;
v = analogRead(vin);
us= (424*v-216564);
Serial.println(v);
Serial.println(us);
}
while (us<=9004 && us>=100){ //these readings are in temp control range
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= interval) {
previousMillis = currentMillis;
v = analogRead(vin);
us= (424*v-216564);
Serial.println(v);
Serial.println(us);
}
if(digitalRead(pin)==HIGH && state==LOW){ //wait for hi pulse at zero crossing
digitalWrite(ledPin,LOW); // if high pulse received execute these 5 lines
delayMicroseconds (us); // if no hi pulse continue waiting in while loop
digitalWrite(ledPin,HIGH);
delayMicroseconds (9100-us);
digitalWrite(ledPin,LOW);
}
}
if (v>532){ // turns off power when maximum temp exceeded
Serial.println(v);
digitalWrite(ledPin,LOW);}
if (v<511){ // turns on full power below minimum temp
Serial.println(v);
digitalWrite(ledPin,HIGH);}
}
```
type or paste code here
