• 2022-06-08
    单片机的P2^0、2^1口分别接发光二极管LED1、LED2,读下列程序:#include<;reg51.h>;sbitLED1=P2^0;sbitLED2=P2^1;unsignedcharCountor1=0,Countor2=0;voidmain(void){TMOD|=0x10;TL1 = 0x00;//设置定时初值 定时50msTH1 = 0x4C;//设置定时初值TR1=1;ET1=1;EA=1;while(1);}voidTime1(void)interrupt3{TL1 = 0x00;//设置定时初值 定时50msTH1 = 0x4C;//设置定时初值Countor1++;Countor2++;if(Countor1==2){LED1=~LED1;Countor1=0;}if(Countor2==8){LED2=~LED2;Countor2=0;}}程序运行结果:
  • 用定时器T1中断控制两个LED以不同周期闪烁,LED1以100ms时间间隔闪烁,LED2以400ms时间间隔闪烁。

    举一反三

    内容

    • 0

      【单选题】分段函数: ,下面程序段中正确的是__________。 A. If x < 0 Then y = 0 If x < 1 Then y = 1 If x < 2 Then y = 2 If x >= 2 Then y = 3 B. If x >= 2 Then y = 3 If x >= 1 Then y = 2 If x > 0 Then y = 1 If x < 0 Then y = 0 C. If x < 0 Then y = 0 ElseIf x > 0 Then y = 1 ElseIf x > 1 Then y = 2 Else y = 3 End If D. If x > =2 Then y = 3 ElseIf x > =1 Then y = 2 ElseIf x > =0 Then y = 1 Else y = 0 End If

    • 1

      第一个LED灯点亮的程序是 A: LED=1; B: LED=0; C: LED1=1; D: LED1=0;

    • 2

      将矩阵[img=544x298]17da662f4927053.png[/img]写成MATLAB语言表达形式,下列正确的是( )。 A: A=[1 0 -1;1 0 1;1 2 1; 1 2 2] B: A=[1 -1 1 2;1 1 1 1;2 0 0 2] C: A=[1 1 1 1;2 0 0 2;1 -1 1 2] D: A=[1 2 1;1 0 -1;1 0 1;1 2 2]

    • 3

      【单选题】如图示代码,下面哪个是正确的输出结果 A. 0  1  2  3  4  5 B. 0  1  2  3  4  5 0  1  2  3  4  5 0  1  2  3  4  5 0  1  2  3  4  5 C. 0  1  2  3  4  5 0  1  2  3  4  5 0  1  2  3  4  5 D. 0  1  2  3  4  5 0  1  2  3  4  5 0  1  2  3  4  5 0  1  2  3  4  5 0  1  2  3  4  5

    • 4

      【单选题】Which of the following matrices does not have the same determinant of matrix B: [1, 3, 0, 2; -2, -5, 7, 4; 3, 5, 2, 1; -1, 0, -9,-5] A. [1, 3, 0, 2; -2, -5, 7, 4; 0, 0, 0, 0; -1, 0, -9, -5] B. [1, 3, 0, 2; -2, -5, 7, 4; 1, 0, 9, 5; -1, 0, -9, -5] C. [1, 3, 0, 2; -2, -5, 7, 4; 3, 5, 2, 1; -3, -5, -2, -1] D. [1, 3, 0, 2; -2, -5, 7, 4; 0, 0, 0, 1; -1, 0, -9, -5]