小编Elm*_*mer的帖子

Arduino:if-compare参数

我正在尝试启动并运行一个小型BMP085气压计项目.我希望能够在不同的操作模式(MODE_PRESSURE和MODE_ALT)之间切换.我有MODE_PRESSUREMODE_ALT定义为const int.

const int MODE_PRESSURE = 1;  // display pressure and temp
const int MODE_ALT      = 2;  // display altitude relative to sea level
int mode;                     // stores the current mode

void setup {
    mode = MODE_PRESSURE;
}

void loop {

    // Read mode button and set mode accordingly
    int buttonPressed = readButtons();

    switch(buttonPressed) {
    case BTN_MODE:
        if(mode == MODE_PRESSURE) { mode = MODE_ALT; }
        if(mode == MODE_ALT) { mode = MODE_PRESSURE; }
        Serial.println(mode); …
Run Code Online (Sandbox Code Playgroud)

c c++ embedded arduino

5
推荐指数
1
解决办法
165
查看次数

标签 统计

arduino ×1

c ×1

c++ ×1

embedded ×1