这些小活动你都参加了吗?快来围观一下吧!>>
电子产品世界 » 论坛首页 » 嵌入式开发 » STM32 » 初学使用STM32L053-Nucleo开发

共15条 2/2 1 2 跳转至
菜鸟
2015-12-18 20:48:33     打赏
11楼

菜鸟
2015-12-18 20:51:29     打赏
12楼

今晚点亮了一个数码管,其中发现用bit关键词会报错,暂还没搞明白原因


菜鸟
2015-12-18 20:52:26     打赏
13楼
#include "mbed.h"
#include "device.h"
 
DigitalIn mybutton(USER_BUTTON);
DigitalOut myled(LED1);
DigitalOut myBZ(D0);
DigitalOut AB(D6);
DigitalOut CP(D7);
BusOut myLEDcom(A0,A1,A2,A3,A4,A5);
unsigned char LED_mode;
unsigned char LEDdata;

void Transmit_SN74H164(unsigned char Data)
{
    unsigned char i;
    for(i=0;i<8;i++)
    {
        CP=0;
     //   _nop_();   
        wait_us(1);     
 //       AB=(bit)(Data&0x80);
      if(Data&0x80){AB=1;}else{AB=0;}
     //   _nop_(); 
     wait_us(1);       
        CP=1;
     //   _nop_();   
     wait_us(1);         
        Data<<=1;
    }           
}
int main() {
//  unsigned char LED_mode;
//  unsigned char LEDdata;
  myLEDcom=0xff;
  while(1) {
    if (mybutton == 0) { // Button is pressed
      myled = !myled; // Toggle the LED state
      myBZ = !myBZ;
      LED_mode++;
      if(LED_mode>9)LED_mode=0;
      switch(LED_mode)
      {
        case 0:  LEDdata=0xc0; break; 
        case 1:  LEDdata=0xf9; break; 
        case 2:  LEDdata=0xa4; break;
        case 3:  LEDdata=0xb0; break;
        case 4:  LEDdata=0x99; break;
        case 5:  LEDdata=0x92; break;
        case 6:  LEDdata=0x82; break;
        case 7:  LEDdata=0xf8; break;
        case 8:  LEDdata=0x80; break;
        case 9:  LEDdata=0x90; break;
      }
   //   wait(0.2); // 200 ms
      myLEDcom=0xff;
      Transmit_SN74H164(LEDdata);
      myLEDcom=0xfe;
      wait(0.2); // 200 ms
    }
  }
}

 


菜鸟
2015-12-18 20:53:25     打赏
14楼
熟悉了几个API

助工
2015-12-29 15:55:10     打赏
15楼
棒棒哒

共15条 2/2 1 2 跳转至

回复

匿名不能发帖!请先 [ 登陆 注册 ]