美文网首页
mbed嵌入式编程(一):闪灯,测量芯片温度

mbed嵌入式编程(一):闪灯,测量芯片温度

作者: 光均 | 来源:发表于2020-04-25 18:11 被阅读0次

    mbed嵌入式编程(一):闪灯blinking,测量芯片温度
    电路板:NUCLEO H743ZI2;编程环境:Arm Compiler V6.13.1

    #include "mbed.h"
    #include "platform/mbed_thread.h"
    
    // Blinking rate in milliseconds
    #define BLINKING_RATE_MS   500
    
    Serial pc(USBTX, USBRX); // tx, rx
    AnalogIn adc(ADC_TEMP);
    AnalogIn adc1(ADC_VREF);
    AnalogIn adc2(ADC_VBAT);
    
    float tempv,temp,adcvref,vbat;
    
    int main()
    {
        pc.printf("Hello World!\n\r");
        DigitalOut led(LED1);   //LED1
        while (true) {
           led = !led;
           tempv = adc.read()* 3.3 ;
           adcvref = adc1.read()* 3.3 ;
           vbat = adc2.read()* 3.3 ;
                 temp = ((tempv - 0.76)/2.5) + 25;
                 pc.printf("temp:%.2f   adc vref:%.2f   vbat:%.2f\n",temp,adcvref,vbat);
           thread_sleep_for(BLINKING_RATE_MS);
        }
    }
    

    仅闪灯代码

    #include "mbed.h"
    #include "platform/mbed_thread.h"
    
    Serial pc(USBTX, USBRX); // tx, rx
    DigitalOut led(LED1);   //LED1
    
    int main()
    {
        pc.printf("Hello World!\n\r");
        while (true) {
           led = !led;
           thread_sleep_for(500);
        }
    }
    

    mbed os2 闪灯

    #include "mbed.h"
    
    DigitalOut myled(LED1);
    
    int main() {
        while(1) {
            myled = 1;
            wait(0.2);
            myled = 0;
            wait(0.2);
        }
    }
    

    相关文章

      网友评论

          本文标题:mbed嵌入式编程(一):闪灯,测量芯片温度

          本文链接:https://www.haomeiwen.com/subject/jaikwhtx.html