EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise
You are here: Home / Topics / pls help PWM fan

pls help PWM fan

|

Microcontroller › 8051 › pls help PWM fan

  • This topic has 0 replies, 1 voice, and was last updated 13 years, 2 months ago by Chan.
Viewing 1 post (of 1 total)
  • Author
    Posts
  • December 19, 2012 at 4:15 pm #4794
    Chan
    Participant

    i want to use two button to control the fan speed  (fast and slow)

     

    this is the code

     

     

    #include <reg52.h>

    unsigned char timer1;

    int time;

    sbit PWM=P1^2;

    void system_Ini()

    {

        TMOD = 0x10;

        TH1 = 0xfe;

        TL1 = 0x33;

        TR1 = 1;

        IE = 0x8A; 

    }

    /**************************************************

    Function: delay_us();

     

    /**************************************************/

    void delay_us(unsigned int x)

    {

        unsigned int i=0;

        for(i=0;i<x;i++)

        {;}

    }

     main()

    { time=50;

      system_Ini();

      while(1)

      {

        P2|=0xff;

        if(P2==0xfe&&time<100)

          {delay_us(1200);

          if(P2==0xfe)

          time+=1;}

        if(P2==0xfd&&time>0)

          {delay_us(1200);

          if(P2==0xfd)

          time-=1;}

        if(timer1>100)

        timer1=0;

        if(timer1<time)

        PWM=0;

        else

        PWM=1;

      }

    }

    /*************************************

     

    *************************************/

    void T1zd(void) interrupt 3    

    {

        TH1 = 0xfe; //11.0592

        TL1 = 0x33;

         timer1++;

    }

     

     i use the software to test 

     

     

     

     

    it shows the code is work?

     

    but will test in hardware

     

    all the thing is not work!! 

     

     

     I don’t know where is the problem can anyone help pls

  • Author
    Posts
Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.
Log In

RSS Recent Posts

  • RC Electronic Speed Control Capacitors February 17, 2026
  • Annex32 / Annex RDS For ESP Micros - A Quick and Dirty Example February 16, 2026
  • Convenient audio FFT module? February 16, 2026
  • CR2/CR123A Batteries In Projects February 16, 2026
  • Harman Kardon radio module BMW noise February 16, 2026

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2026 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise