跪求wifiduino中遇到问题-Arduino中文社区 - Powered by Discuz!

Arduino中文社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 3288|回复: 4

跪求wifiduino中遇到问题

[复制链接]
发表于 2018-6-16 07:14 来自手机 | 显示全部楼层 |阅读模式
[mw_shl_code=cpp,true]/*
* Blinker WiFi CAR, support WiFiduino
*/

#define BLINKER_PRINT    Serial
#define BLINKER_WIFI

#include <Blinker.h>

char ssid[] = "<Your WiFi network SSID or name>";
char pswd[] = "<Your WiFi network WPA password or WEP key>";

#define L_DIR_PIN       14
#define L_PWM_PIN       16
#define R_DIR_PIN       4
#define R_PWM_PIN       5
#define C_BAR_PIN       12

uint32_t car_os_time = millis();
bool isWarn = false;

void blinker_car_init()
{
    pinMode(L_DIR_PIN, OUTPUT);
    pinMode(L_PWM_PIN, OUTPUT);
    pinMode(R_DIR_PIN, OUTPUT);
    pinMode(R_PWM_PIN, OUTPUT);

    pinMode(C_BAR_PIN, INPUT_PULLUP);

// #if defined(ESP8266)
    analogWriteRange(255);
// #endif
}

void blinker_car_parse(uint8_t &_L_PWM, bool &_L_DIR, uint8_t &_R_PWM, bool &_R_DIR)
{
    uint8_t xAxis = Blinker.joystick(J_Xaxis);
    uint8_t yAxis = Blinker.joystick(J_Yaxis);
    bool    isStop = false;

    if (yAxis < 128) {
        _L_DIR = true;
        _R_DIR = true;

        _L_PWM = map(abs(128-yAxis), 0, 128, 128, 255);
        _R_PWM = map(abs(128-yAxis), 0, 128, 128, 255);
    }
    else if (yAxis > 128) {
        _L_DIR = false;
        _R_DIR = false;

        _L_PWM = map(abs(128-yAxis), 0, 128, 128, 255);
        _R_PWM = map(abs(128-yAxis), 0, 128, 128, 255);
    }
    else {
        isStop = true;

        _L_PWM = 0;
        _R_PWM = 0;
    }

    if (xAxis < 128) {
        if (isStop) {
            _L_DIR = false;
            _R_DIR = true;

            _L_PWM = map(abs(128-xAxis), 0, 128, 128, 255);
            _R_PWM = map(abs(128-xAxis), 0, 128, 128, 255);
        }
        else {
            _L_PWM -= map(abs(128-xAxis), 0, 128, 0, 128);
        }
    }
    else if (xAxis > 128) {
        if (isStop) {
            _L_DIR = true;
            _R_DIR = false;
        }
        else {
            _R_PWM -= map(abs(128-xAxis), 0, 128, 0, 128);
        }
    }
    else {
        if (isStop) {
            _L_PWM = 0;
            _R_PWM = 0;
        }
    }
}

void blinker_car_control(uint8_t cl_pwm, bool cl_dir, uint8_t cr_pwm, bool cr_dir)
{
    digitalWrite(L_DIR_PIN, cl_dir);
    digitalWrite(R_DIR_PIN, cr_dir);
    analogWrite(L_PWM_PIN, cl_pwm);
    analogWrite(R_PWM_PIN, cr_pwm);
}

void blinker_car_detect()
{
    if (!digitalRead(C_BAR_PIN)) {
        if (!isWarn) {
            Blinker.vibrate();
            isWarn = true;
            car_os_time = millis();
        }
        else if (millis() - car_os_time >= 5000) {
            isWarn = false;
        }
    }
    else {
        isWarn = false;
    }
}

void setup()
{
    Serial.begin(115200);

    blinker_car_init();

    Blinker.begin(ssid, pswd);
}

void loop()
{
    Blinker.run();

    uint8_t L_PWM = 0;
    uint8_t R_PWM = 0;
    bool    L_DIR = false;
    bool    R_DIR = false;

    blinker_car_parse(L_PWM, L_DIR, R_PWM, R_DIR);

    blinker_car_control(L_PWM, L_DIR, R_PWM, R_DIR);

    blinker_car_detect();

#if defined(BLINKER_CAR_DEBUG)
    BLINKER_LOG4("L_PWM: ", L_PWM, "  | L_DIR: ", L_DIR);
    BLINKER_LOG4("R_PWM: ", R_PWM, "  | R_DIR: ", R_DIR);
    Blinker.delay(2000);
#endif
}[/mw_shl_code]

评分

参与人数 1抽奖次数 +1 收起 理由
coloz + 1

查看全部评分

 楼主| 发表于 2018-6-16 07:16 来自手机 | 显示全部楼层
错了是这个
 楼主| 发表于 2018-6-16 07:17 来自手机 | 显示全部楼层
Arduino:1.8.5 (Windows 7), 开发板:"WiFiduino, 80 MHz, 4M (1M SPIFFS), v2 Lower Memory, Disabled, None, Only Sketch, 921600"In file included from D:\Arduino\libraries\blinker-library-master\src/Adapters/BlinkerArduinoWS.h:4:0,                 from D:\Arduino\libraries\blinker-library-master\src/BlinkerSimpleESP8266_WS.h:4,                 from D:\Arduino\libraries\blinker-library-master\src/Blinker.h:15,                 from D:\Arduino\libraries\blinker-library-master\examples\Blinker_Button\Button_WiFi\Button_WiFi.ino:4:\Arduino\libraries\blinker-library-master\src/Blinker/BlinkerProtocol.h:396:17: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix]                 "/\\  _`\\ /\\_ \\    __        /\\ \\               v"BLINKER_VERSION"\n"                 ^D:\Arduino\libraries\blinker-library-master\src/Blinker/BlinkerProtocol.h:404:17: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix]                 "   ___  ___      __    v"BLINKER_VERSION"\n"                 ^In file included from D:\Arduino\libraries\blinker-library-master\src/Blinker/BlinkerProtocol.h:4:0,                 from D:\Arduino\libraries\blinker-library-master\src/Adapters/BlinkerArduinoWS.h:4,                 from D:\Arduino\libraries\blinker-library-master\src/BlinkerSimpleESP8266_WS.h:4,                 from D:\Arduino\libraries\blinker-library-master\src/Blinker.h:15,                 from D:\Arduino\libraries\blinker-library-master\examples\Blinker_Button\Button_WiFi\Button_WiFi.ino:4:\Arduino\libraries\blinker-library-master\src/Blinker/BlinkerApi.h: In constructor 'BlinkerButton::BlinkerButton()':\Arduino\libraries\blinker-library-master\src/Blinker/BlinkerApi.h:61:50: warning: passing NULL to non-pointer argument 1 of 'String::String(int, unsigned char)' [-Wconversion-null]             : buttonName(NULL), buttonState(false)                                                  ^D:\Arduino\libraries\blinker-library-master\src/Blinker/BlinkerApi.h: In constructor 'BlinkerSlider::BlinkerSlider()':\Arduino\libraries\blinker-library-master\src/Blinker/BlinkerApi.h:81:46: warning: passing NULL to non-pointer argument 1 of 'String::String(int, unsigned char)' [-Wconversion-null]             : sliderName(NULL), sliderValue(0)                                              ^D:\Arduino\libraries\blinker-library-master\src/Blinker/BlinkerApi.h: In constructor 'BlinkerToggle::BlinkerToggle()':\Arduino\libraries\blinker-library-master\src/Blinker/BlinkerApi.h:99:50: warning: passing NULL to non-pointer argument 1 of 'String::String(int, unsigned char)' [-Wconversion-null]             : toggleName(NULL), toggleState(false)                                                  ^D:\Arduino\libraries\blinker-library-master\src/Blinker/BlinkerApi.h: In constructor 'BlinkerRGB::BlinkerRGB()':\Arduino\libraries\blinker-library-master\src/Blinker/BlinkerApi.h:117:27: warning: passing NULL to non-pointer argument 1 of 'String::String(int, unsigned char)' [-Wconversion-null]             : rgbName(NULL)                           ^In file included from D:\Arduino\libraries\blinker-library-master\src/Blinker/BlinkerProtocol.h:4:0,                 from D:\Arduino\libraries\blinker-library-master\src/Adapters/BlinkerArduinoWS.h:4,                 from D:\Arduino\libraries\blinker-library-master\src/BlinkerSimpleESP8266_WS.h:4,                 from D:\Arduino\libraries\blinker-library-master\src/Blinker.h:15,                 from D:\Arduino\libraries\blinker-library-master\examples\Blinker_Button\Button_WiFi\Button_WiFi.ino:4:\Arduino\libraries\blinker-library-master\src/Blinker/BlinkerApi.h: In member function 'void BlinkerApi<roto>::parse(String, bool)':\Arduino\libraries\blinker-library-master\src/Blinker/BlinkerApi.h:3011:67: error: 'data' was not declared in this scope                         JsonObject& root = jsonBuffer.parseObject(data);                                                                   ^"WiFiClient.h" 对应多个库 已使用: C:\Users\Administrator.BF-20180603JOVG\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.4.0\libraries\ESP8266WiFi 未使用:D:\Arduino\libraries\WiFi 未使用:D:\Arduino\libraries\WiFi 未使用:D:\Arduino\libraries\WiFi 未使用:D:\Arduino\libraries\WiFiexit status 1为开发板 WiFiduino 编译时出错。在文件 -> 首选项开启“编译过程中显示详细输出”选项这份报告会包含更多信息。
发表于 2018-6-16 09:34 | 显示全部楼层
我测试了,编译是正常的,建议你更新下blinker库,再试试
https://github.com/blinker-iot/blinker-library/archive/master.zip
发表于 2018-6-17 18:22 | 显示全部楼层
我好像遇到过,你ide存在多个重名的库,把没用的删掉就好了
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|Archiver|手机版|Arduino中文社区

GMT+8, 2024-11-28 21:51 , Processed in 0.168268 second(s), 16 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表