能量得到功率

#include <stdio.h>

//多个变量共同作用才能得到一个值  最终才能得到我们想要效果   
typedef struct _device_power
{
    float voltage;
    float current;
    float direction;
    float power;
}Device_power;

static Device_power component; 

int main(void) {
    
    float power = component.power;
    
    while(1)
    {
        //通过万用表 电压档 得到电压 
        //通过万用表 电流档 得到电流
        component.voltage = 3.46f;
        component.current = 1.2f;
        power = component.voltage * component.current;
        printf("power is %f\n",power);
        
        usleep(10000);
        
    }
    
        
    return 0;
}

猜你喜欢

转载自www.cnblogs.com/nowroot/p/13199627.html
今日推荐