#include <SN8F5703.h>
#define uint unsigned int
void DELAY(uint t);
sbit KEY=P2^0;
sbit LED=P1^1;
void DELAY(uint t)
{
while(--t);
}
void main ()
{
uint CYCLE=1000;
uint PWM_LOW = 0;
P0M=0xff;
P1M=0xff;
P0=0x00;
while(1)
{
LED=0;
DELAY(1000);
for(PWM_LOW =1; PWM_LOW < CYCLE; PWM_LOW++)//CYCLE-1000 -PWM_LOW 2-3-4-998//
{
LED=0;
DELAY(PWM_LOW); //off++//
LED=1;
DELAY(CYCLE-PWM_LOW); //LED_ON--//
}
for(PWM_LOW=CYCLE-1; PWM_LOW>0;PWM_LOW--)
{
LED=1;
DELAY(CYCLE-PWM_LOW); //LED_On++//
LED=0;
DELAY(PWM_LOW); //LED_Off--//
}
}
}
版权声明:本文为CSDN博主「lj2407727730」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/lj2407727730/article/details/122640880
#include <SN8F5703.h>
#define uint unsigned int
void DELAY(uint t);
sbit KEY=P2^0;
sbit LED=P1^1;
void DELAY(uint t)
{
while(--t);
}
void main ()
{
uint CYCLE=1000;
uint PWM_LOW = 0;
P0M=0xff;
P1M=0xff;
P0=0x00;
while(1)
{
LED=0;
DELAY(1000);
for(PWM_LOW =1; PWM_LOW < CYCLE; PWM_LOW++)//CYCLE-1000 -PWM_LOW 2-3-4-998//
{
LED=0;
DELAY(PWM_LOW); //off++//
LED=1;
DELAY(CYCLE-PWM_LOW); //LED_ON--//
}
for(PWM_LOW=CYCLE-1; PWM_LOW>0;PWM_LOW--)
{
LED=1;
DELAY(CYCLE-PWM_LOW); //LED_On++//
LED=0;
DELAY(PWM_LOW); //LED_Off--//
}
}
}
版权声明:本文为CSDN博主「lj2407727730」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/lj2407727730/article/details/122640880
暂无评论