The graph knows low-level light, high-level off
Control the first LED1 light out program code, as follows
1#include <reg52.h>2 #defineUchar8 unsigned char3 #defineuint16 unsigned int4Sbit led1=p1^0;5 /*****************************/6 //function Name: delayms ()7 //function function: Delay8 //entry function: Delay millisecond9 //export function: NoneTen /********* *******************/ One voiddelayms (uint16 val) A { - uint16 i,j; - for(i=0; i<val;i++) the for(j=0;j<113; j + +); - - } - + voidMain () - { + A while(1) at { -led1=0; -Delayms ( +); -led1=1; -Delayms ( +); - in } - to}
——————————————————————————————————————————————————————————————————————————————————————————————————————————————— —————————
Running Light Program code:
1#include <reg52.h>2#include <intrins.h>3 #defineUchar8 unsigned char4 #defineuint16 unsigned int5 #defineLED P16 /*****************************/7 //function Name: delayms ()8 //function function: Delay9 //entry function: Delay millisecondTen //export function: None One /********* *******************/ A voiddelayms (uint16 val) - { - uint16 i,j; the for(i=0; i<val;i++) - for(j=0;j<113; j + +); - - } + - voidMain () + { A at inti; - - while(1) - { -Led=0xFF;//here the port is all set to 1111 1111, which is equivalent to the total loss - in for(i=0;i<8; i++) - { to +led=led<<1;//left-shift loop selected -Delayms ( +); the * } $ Panax Notoginseng } - the}
P1.7 |
P1.6 |
P1.5 |
P1.4 |
P1.3 |
P1.2 |
P1.1 |
P1.0 |
|
|
|
|
|
|
|
|
1 |
1 |
1 |
1 |
1 |
1 |
1 |
0 |
1 |
1 |
1 |
1 |
1 |
1 |
0 |
0 |
1 |
1 |
1 |
1 |
1 |
0 |
0 |
0 |
1 |
1 |
1 |
1 |
0 |
0 |
0 |
0 |
1 |
1 |
1 |
0 |
0 |
0 |
0 |
0 |
1 |
1 |
0 |
0 |
0 |
0 |
0 |
0 |
1 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
Experiment Board Phenomenon:
Light on number 1th
1, 2 bright
1, 2, 3 bright
1, 2, 3, 4 bright
。。。。。。
1, 2, 3 ..... 8 All Bright
——————————————————————————————————————————————————————————————————————————————————————————————
Marquee Program code:
1#include <reg52.h>2#include <intrins.h>3 #defineUchar8 unsigned char4 #defineuint16 unsigned int5 #defineLED P16 /*****************************/7 //function Name: delayms ()8 //function function: Delay9 //entry function: Delay millisecondTen //export function: None One /********* *******************/ A voiddelayms (uint16 val) - { - uint16 i,j; the for(i=0; i<val;i++) - for(j=0;j<113; j + +); - - } + - voidMain () + { A atLED =0xFE; - - while(1) - { -Led=_crol_ (LED,1); -Delayms ( +); in - } to +}
Only one LED light is lit.
Re-pick the first day of single-chip LED lights