main.c

来自「led buttons yanshishuoming」· C语言 代码 · 共 51 行

C
51
字号
// This program is designed for STR-P711 Board.
// It shows how to work with button and leds

#include "system.h"
#include "leds.h"
#include <iostr711.h>

#define BUT_PRESSED    IOPORT1_PD_bit.no14

//it's a simple delay
void Delay (unsigned long a) { while (--a!=0); }

// variable for pressed button
char push_but    = 1;

int main()
{

  // Init frecuency
  FreqInit();

  // System init
  SysInit();

  // Init leds
  InitLeds();
  Led1_On();
  Led2_Off();


  // loop forever
  while(1) {


    // button BUT is pressed
    if((BUT_PRESSED == 1)&&(push_but == 1)) {
      Led1_Off();
      Led2_On();
      push_but = 0;
    }
    if((BUT_PRESSED == 0)&&(push_but == 0)) {
      Led1_On();
      Led2_Off();
      push_but = 1;
    }


  }

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?