Skip to content

Instantly share code, notes, and snippets.

@PinLin
Last active April 16, 2018 17:37
Show Gist options
  • Save PinLin/1eea336397a4b0e0b0fc615504f16133 to your computer and use it in GitHub Desktop.
Save PinLin/1eea336397a4b0e0b0fc615504f16133 to your computer and use it in GitHub Desktop.
是 89S51 ouoo
#include "reg51.h"
//#include <at89x51.h>
bit lightoff = 1;
bit lighton = 0;
sbit P1_0 = P1^0;
sbit P1_1 = P1^1;
sbit P1_2 = P1^2;
sbit P1_3 = P1^3;
sbit P1_4 = P1^4;
sbit P1_5 = P1^5;
sbit P1_6 = P1^6;
sbit P1_7 = P1^7;
void delay_1500ms();
int main () {
P1 = 0xFF;
while (1) {
delay_1500ms();
P1_0 = lighton;
delay_1500ms();
P1_1 = lighton;
delay_1500ms();
P1_2 = lighton;
delay_1500ms();
P1_3 = lighton;
delay_1500ms();
P1_4 = lighton;
delay_1500ms();
P1_5 = lighton;
delay_1500ms();
P1_6 = lighton;
delay_1500ms();
P1_7 = lighton;
delay_1500ms();
P1_7 = lightoff;
delay_1500ms();
P1_6 = lightoff;
delay_1500ms();
P1_5 = lightoff;
delay_1500ms();
P1_4 = lightoff;
delay_1500ms();
P1_3 = lightoff;
delay_1500ms();
P1_2 = lightoff;
delay_1500ms();
P1_1 = lightoff;
delay_1500ms();
P1_0 = lightoff;
} // end of while(1)
} // end of main()
void delay_1500ms() {
unsigned short kk;
for (kk = 0; kk < 33000; kk++);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment