Potentiometer control AC Dimmer by ELECTRONOOB

(Read 481 times)
Potentiometer control AC Dimmer by ELECTRONOOB on: October 03, 2019, 03:32:42 PM
You might watched Potentiometer AC Dimmer by ELECTRONOOB. It's great but I want to make the same project with ESP8266. what do I need to change in the code to make It work. I have some problem understanding this following parts of the code.

  PCICR |= (1 << PCIE0);    //enable PCMSK0 scan                                                 
  PCMSK0 |= (1 << PCINT0);  //Set pin D8 trigger an interrupt on state change. Input from optocoupler

&

ISR(PCINT0_vect){
  /////////////////////////////////////               //Input from optocoupler
  if(PINB & B00000001){                               //We make an AND with the pin state register, We verify if pin 8 is HIGH???
    if(last_CH1_state == 0){                          //If the last state was 0, then we have a state change...
      detectado=1;                                    //We haev detected a state change!
    }
  }
  else if(last_CH1_state == 1){                       //If pin 8 is LOW and the last state was HIGH then we have a state change     
    detectado=1;                                      //We haev detected a state change!
    last_CH1_state = 0;                               //Store the current state into the last state for the next loop
    }
}



Re: Potentiometer control AC Dimmer by ELECTRONOOB Reply #1 on: October 15, 2019, 11:45:13 PM
With this line PCMSK0 |= (1 << PCINT0);  / we make D8 to be able to generate an interrumption. Each time D8 will cahneg its state from H to L or from L to H we go to the interrumption vecttor which is that ISR routine. And there we detect the state of D8 and set the detected variable to 1 or 0. That's it.