This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

problem with ac dimmer circuit with nRF51822

hi,

i tried to make a ac dimmer circuit controlled with dc

i use nrf51822

this is my dimmer circuit

image description

aaand this one is zero crossing detector

image description

finally this is my mbed code;

DigitalOut trigger(p15);

DigitalIn zero(p14);

int main()

{

    while(1)  

    {

        if (zero==1) 

        {

            wait_us (5000);  
                
            trigger = 1;      
             
            wait_us (100);  

            trigger = 0;     

        } 

    }

}

i just want to dim my light %50, but it always blinking.

can anyone help me and tell me what is my mistake?

Parents
  • include "mbed.h"
    
    InterruptIn zero(p5);
    
    DigitalOut trigger(p11);
    
    Timeout dim;
    
    void event()
    
    {
    
        trigger = 1;
    
        wait_ms (1);
    
        trigger = 0;
    
    }
    
    void dimmer()
    
    {
    
        dim.attach(&event,0.005);
    
    }
    
    int main()
    
    {
    
        //zero.mode(PullDown);
    
        while (1)
    
        {
    
            zero.rise(&dimmer);
    
        }
    
    }
    

    this code solved my problem.

Reply
  • include "mbed.h"
    
    InterruptIn zero(p5);
    
    DigitalOut trigger(p11);
    
    Timeout dim;
    
    void event()
    
    {
    
        trigger = 1;
    
        wait_ms (1);
    
        trigger = 0;
    
    }
    
    void dimmer()
    
    {
    
        dim.attach(&event,0.005);
    
    }
    
    int main()
    
    {
    
        //zero.mode(PullDown);
    
        while (1)
    
        {
    
            zero.rise(&dimmer);
    
        }
    
    }
    

    this code solved my problem.

Children
No Data
Related