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 / Replies / Hii Ajish, The Programing

Hii Ajish, The Programing

|

Microcontroller › 8051 › GENERATING VARIABLE PWM › Hii Ajish, The Programing

July 24, 2012 at 8:55 am #8319
Varun Srivastava
Participant

Hii Ajish,

 

The Programing part i have done yet is using 4 push buttons to change d value of PWM output. Now this is the next step in my project design dat i want to do it using only two push buttons to either increase or decrease the duty cycle of the PWM.

 

My present program is….

 

#include <reg51.h>

sbit ONE=P2^7;

sbit TWO=P2^6;

sbit THREE=P2^5;

sbit FOUR=P2^4;

sbit FIVE=P2^3;

sbit SIX=P2^2;

sbit SEVEN=P2^1;

sbit EIGHT=P2^0;

sbit MTR=P1^0;

void MSDelay(int value);

void main()

{

unsigned int on,off;

ONE=1;

TWO=1;

THREE=1;

FOUR=1;

FIVE=1;

SIX=1;

SEVEN=1;

EIGHT=1;

while(1)

{             

                if (ONE==0)

                                {

                                 FIVE=0;

                                 SIX=1;

                                 SEVEN=1;

                                 EIGHT=1;

                                 while(FIVE==0 && TWO==1 && THREE==1 && FOUR==1)

                                 {

                                  on=2;

                                  off=8;

                                  MTR=1;

                                  MSDelay(on);

                                  MTR=0;

                                  MSDelay(off);

                                 }

                                }

                else if (TWO==0)

                                {

                                 FIVE=1;

                                 SIX=0;

                                 SEVEN=1;

                                 EIGHT=1;

                                 while(SIX==0 && ONE==1 && THREE==1 && FOUR==1)

                                 {

                                  on=3;

                                  off=7;

                                  MTR=1;

                                  MSDelay(on);

                                  MTR=0;

                                  MSDelay(off);

                                 }

                                }

                else if (THREE==0)

                                {

                                 FIVE=1;

                                 SIX=1;

                                 SEVEN=0;

                                 EIGHT=1;

                                 while(SEVEN==0 && ONE==1 && TWO==1 && FOUR==1)

                                 {

                                  on=5;

                                  off=5;

                                  MTR=1;

                                  MSDelay(on);

                                  MTR=0;

                                  MSDelay(off);

                                  }

                                }

                else if (FOUR==0)

                                {

                                 FIVE=1;

                                 SIX=1;

                                 SEVEN=1;

                                 EIGHT=0;

                                 while(EIGHT==0 && ONE==1 && TWO==1 && THREE==1)

                                 {

                                 MTR=1;

                                 }

                 else

                                {

                                 MTR=1;

                                }

                }

}                                                 

void MSDelay(int value)

{

int x;

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

}

 

 

 

If u cn help me where to change d logic in dis present program…looking forward for it…!!

RSS Recent Posts

  • The Analog Gods Hate Me July 10, 2025
  • Display TFT ST7789 (OshonSoft Basic). July 10, 2025
  • Fixing board, Easy question HEX SCHMITT July 10, 2025
  • Can I make two inputs from one?? July 10, 2025
  • Home Smoke detectors are all Beeping Batteries are not dead.??? July 9, 2025

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2025 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