• 女性之声——全国妇联 2019-03-19
  • 【理上网来·辉煌十九大】德国北威州经济部长:十九大报告表明中国有能力为世界做出更多贡献 2019-03-11
  • 全国小麦收获进度过八成 2019-03-07
  • 【人事】中共临汾市委组织部公示3名拟任职干部 2019-03-07
  • 这泼猴,物理。古文,哲学,基础语文,那一项没出丑?看着就想笑 2019-02-20
  • 云南理发店老板涉嫌杀害女演员因办卡纠纷起杀心 2019-02-20
  • 1至5月我区为企业和社会减负4200余万元 2019-02-09
  • 【学习时刻】参会专家盛小云:坚定文化自信,用高尚的作品引领社会风尚 2019-01-28
  • 绘就生态文明新画卷—甘南州造林绿化工作纪实 2019-01-28
  • 某些人总是用“客观事实”来为自己壮胆,实际上根本不懂什么是“客观事实。 2019-01-12
  • 圣洁的雪山文章中国国家地理网 2018-11-22
  • 崇尚英雄 精忠报国——我们家的报国故事 2018-11-22
  • 618史上最壕“买家”现身 Google以 5.5亿美元投资京东 2018-11-21
  • 看好啦!是时候表演真正的技术了 2018-11-21
  • 日本大阪6.1级地震已致4人死亡 370多人受伤 2018-11-20
  • 打印

    时时彩一天赚2000技巧: [UNO] 为开发板Arduino UNO编译时出错

    [复制链接]
    2221|12
    跳转到指定楼层
    楼主
    由于初学,实在看不出来到底为什么老是编译失败,求各位大神的指导

    主程序代码:
    1. #include"Light.h"
    2. #include"Arduino.h"
    3. Light light(13,11,12);
    4. void setup() {
    5. }
    6. void loop() {
    7.   light.on("Pink");

    8. }
    复制代码

    Light.h
    1. #ifndef Light_h
    2. #define Light_h
    3. #include"Arduino.h"

    4. class Light{
    5.   public:
    6.   Light(int R,int G,int B);
    7.   void on(char on[]);
    8.   void off();
    9.   void self(int Ranalog,int Ganalog,int Banalog);
    10.   private:
    11.   int Red;
    12.   int Blue;
    13.   int Green;
    14. };
    15. #endif
    复制代码

    Light.cpp
    1. #include"Arduino.h"
    2. #include"Light.h"
    3.   Light::Light(int R,int G,int B){
    4.     int Red=R;
    5.     int Blue=B;
    6.     int Green=G;
    7.     pinMode(Red,OUTPUT);
    8.     pinMode(Blue.OUTPUT);
    9.     pinMode(Green,OUTPUT);
    10.   }
    11.   void Light::on(char on[]){
    12.     if(on[0]=="R"){
    13.       digitalWrite(Red,HIGH);
    14.       digitalWrite(Blue,LOW);
    15.       digitalWrite(Green,LOW);
    16.     }  
    17.     if(on[0]=="G"){
    18.       digitalWrite(Red,LOW);
    19.       digitalWrite(Blue,LOW);
    20.       digitalWrite(Green,HIGH);
    21.     }
    22.     if(on[0]=="B"){
    23.       digitalWrite(Red,LOW);
    24.       digitalWrite(Blue,HIGH);
    25.       digitalWrite(Green,LOW);
    26.     }
    27.     if(on[0]=="Y"){
    28.       digitalWrite(Red,HIGH);
    29.       digitalWrite(Blue,LOW);
    30.       digitalWrite(Green,HIGH);
    31.     }  
    32.     if(on[0]=="P"){
    33.       digitalWrite(Red,HIGH);
    34.       digitalWrite(Blue,HIGH);
    35.       digitalWrite(Green,LOW);
    36.     }  
    37.     if(on[0]=="C"){
    38.       digitalWrite(Red,LOW);
    39.       digitalWrite(Blue,HIGH);
    40.       digitalWrite(Green,HIGH);
    41.     }  
    42.     if(on[0]=="W"){
    43.       digitalWrite(Red,HIGH);
    44.       digitalWrite(Blue,HIGH);
    45.       digitalWrite(Green,HIGH);
    46.     }  
    47.   }
    48.   void Light::off(){
    49.     digitalWrite(Red,LOW);
    50.     digitalWrite(Blue,LOW);
    51.     digitalWrite(Green,LOW);
    52.   }
    53.   
    54.   void Light::self(int Ranalog,int Ganalog,int Banalog){
    55.     if(Red!=11||Red!=10||Red!=9||Red!=6||Red!=5||Red!=3){
    56.       if(Ranalog<=512){
    57.         digitalWrite(Red,LOW);
    58.       }
    59.       else{
    60.         digitalWrite(Red,HIGH);
    61.       }
    62.     }
    63.     else{
    64.       analogWrite(Red,Ranalog);
    65.     }
    66.     if(Blue!=11||Blue!=10||Blue!=9||Blue!=6||Blue!=5||Blue!=3){
    67.       if(Banalog<=512){
    68.         digitalWrite(Blue,LOW);
    69.       }
    70.       else{
    71.         digitalWrite(Blue,HIGH);
    72.       }
    73.     }
    74.     else{
    75.       analogWrite(Blue,Banalog);
    76.     }
    77.     if(Green!=11||Green!=10||Green!=9||Green!=6||Green!=5||Green!=3){
    78.       if(Ganalog<=512){
    79.         digitalWrite(Green,LOW);
    80.       }
    81.       else{
    82.         digitalWrite(Green,HIGH);
    83.       }
    84.     }
    85.     else{
    86.       analogWrite(Green,Ganalog);
    87.     }
    88.   }
    89.   
    复制代码
    沙发
     楼主 | 2018-7-5 13:05 | 只看该作者
    这是自己编的想实现控制RGB的一个库,却在使用时总是编译失败

    评论

    dirtwillfly 2018-7-5 14:23 回复TA
    什么错误提示?发上来看看 
    板凳
    | 2018-7-5 15:35 | 只看该作者
    贴个编译时的图看看
    地板
     楼主 | 2018-7-8 16:38 | 只看该作者
    Arduino:1.8.5 (Windows 7), 开发板:"Arduino/Genuino Uno"

    C:\Program Files (x86)\Arduino\arduino-builder -dump-prefs -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\Administrator\Documents\Arduino\libraries -fqbn=arduino:avr:uno -ide-version=10805 -build-path C:\Users\ADMINI~1\AppData\Local\Temp\arduino_build_143712 -warnings=all -build-cache C:\Users\ADMINI~1\AppData\Local\Temp\arduino_cache_753323 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avr-gcc.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -verbose C:\Users\Administrator\Documents\Arduino\sketch_jul04a\sketch_jul04a.ino
    C:\Program Files (x86)\Arduino\arduino-builder -compile -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\Administrator\Documents\Arduino\libraries -fqbn=arduino:avr:uno -ide-version=10805 -build-path C:\Users\ADMINI~1\AppData\Local\Temp\arduino_build_143712 -warnings=all -build-cache C:\Users\ADMINI~1\AppData\Local\Temp\arduino_cache_753323 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avr-gcc.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -verbose C:\Users\Administrator\Documents\Arduino\sketch_jul04a\sketch_jul04a.ino
    Using board 'uno' from platform in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr
    Using core 'arduino' from platform in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr
    Detecting libraries used...
    "C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10805 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard" "C:\Users\ADMINI~1\AppData\Local\Temp\arduino_build_143712\sketch\sketch_jul04a.ino.cpp" -o "nul"
    "C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10805 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard" "C:\Users\ADMINI~1\AppData\Local\Temp\arduino_build_143712\sketch\Light.cpp" -o "nul"
    Generating function prototypes...
    "C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10805 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard" "C:\Users\ADMINI~1\AppData\Local\Temp\arduino_build_143712\sketch\sketch_jul04a.ino.cpp" -o "C:\Users\ADMINI~1\AppData\Local\Temp\arduino_build_143712\preproc\ctags_target_for_gcc_minus_e.cpp"
    "C:\Program Files (x86)\Arduino\tools-builder\ctags\5.8-arduino11/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "C:\Users\ADMINI~1\AppData\Local\Temp\arduino_build_143712\preproc\ctags_target_for_gcc_minus_e.cpp"
    正在编译项目...
    "C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -Wall -Wextra -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10805 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard" "C:\Users\ADMINI~1\AppData\Local\Temp\arduino_build_143712\sketch\Light.cpp" -o "C:\Users\ADMINI~1\AppData\Local\Temp\arduino_build_143712\sketch\Light.cpp.o"
    In file included from C:\Users\ADMINI~1\AppData\Local\Temp\arduino_build_143712\sketch\Light.cpp:1:0:

    C:\Users\ADMINI~1\AppData\Local\Temp\arduino_build_143712\sketch\Light.cpp: In constructor 'Light::Light(int, int, int)':

    C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:44:16: error: expected unqualified-id before numeric constant

    #define OUTPUT 0x1

                    ^

    C:\Users\ADMINI~1\AppData\Local\Temp\arduino_build_143712\sketch\Light.cpp:8:18: note: in expansion of macro 'OUTPUT'

         pinMode(Blue.OUTPUT);

                      ^

    C:\Users\ADMINI~1\AppData\Local\Temp\arduino_build_143712\sketch\Light.cpp: In member function 'void Light::on(char*)':

    C:\Users\ADMINI~1\AppData\Local\Temp\arduino_build_143712\sketch\Light.cpp:12:15: warning: comparison with string literal results in unspecified behaviour [-Waddress]

         if(on[0]=="R"){

                   ^

    C:\Users\ADMINI~1\AppData\Local\Temp\arduino_build_143712\sketch\Light.cpp:12:15: warning: ISO C++ forbids comparison between pointer and integer [-fpermissive]

    C:\Users\ADMINI~1\AppData\Local\Temp\arduino_build_143712\sketch\Light.cpp:17:15: warning: comparison with string literal results in unspecified behaviour [-Waddress]

         if(on[0]=="G"){

                   ^

    C:\Users\ADMINI~1\AppData\Local\Temp\arduino_build_143712\sketch\Light.cpp:17:15: warning: ISO C++ forbids comparison between pointer and integer [-fpermissive]

    C:\Users\ADMINI~1\AppData\Local\Temp\arduino_build_143712\sketch\Light.cpp:22:15: warning: comparison with string literal results in unspecified behaviour [-Waddress]

         if(on[0]=="B"){

                   ^

    C:\Users\ADMINI~1\AppData\Local\Temp\arduino_build_143712\sketch\Light.cpp:22:15: warning: ISO C++ forbids comparison between pointer and integer [-fpermissive]

    C:\Users\ADMINI~1\AppData\Local\Temp\arduino_build_143712\sketch\Light.cpp:27:15: warning: comparison with string literal results in unspecified behaviour [-Waddress]

         if(on[0]=="Y"){

                   ^

    C:\Users\ADMINI~1\AppData\Local\Temp\arduino_build_143712\sketch\Light.cpp:27:15: warning: ISO C++ forbids comparison between pointer and integer [-fpermissive]

    C:\Users\ADMINI~1\AppData\Local\Temp\arduino_build_143712\sketch\Light.cpp:32:15: warning: comparison with string literal results in unspecified behaviour [-Waddress]

         if(on[0]=="P"){

                   ^

    C:\Users\ADMINI~1\AppData\Local\Temp\arduino_build_143712\sketch\Light.cpp:32:15: warning: ISO C++ forbids comparison between pointer and integer [-fpermissive]

    C:\Users\ADMINI~1\AppData\Local\Temp\arduino_build_143712\sketch\Light.cpp:37:15: warning: comparison with string literal results in unspecified behaviour [-Waddress]

         if(on[0]=="C"){

                   ^

    C:\Users\ADMINI~1\AppData\Local\Temp\arduino_build_143712\sketch\Light.cpp:37:15: warning: ISO C++ forbids comparison between pointer and integer [-fpermissive]

    C:\Users\ADMINI~1\AppData\Local\Temp\arduino_build_143712\sketch\Light.cpp:42:15: warning: comparison with string literal results in unspecified behaviour [-Waddress]

         if(on[0]=="W"){

                   ^

    C:\Users\ADMINI~1\AppData\Local\Temp\arduino_build_143712\sketch\Light.cpp:42:15: warning: ISO C++ forbids comparison between pointer and integer [-fpermissive]

    exit status 1
    为开发板 Arduino/Genuino Uno 编译时出错。
    5
     楼主 | 2018-7-8 16:39 | 只看该作者
    上面是错误信息
    6
    | 2018-7-8 22:03 | 只看该作者

    上面有错误提示,根据定位的行,逐条看看是不是确定有问题
    7
    | 2018-7-8 22:03 | 只看该作者
    08.    pinMode(Blue.OUTPUT);

    应该是逗号 pinMode(Blue,OUTPUT);
    8
    | 2018-7-15 10:48 | 只看该作者
    9
    | 2018-7-28 10:44 | 只看该作者
    点赞
    10
    | 2018-8-22 21:55 | 只看该作者
    我以前用在Sublime Text下编写并通过编译的代码,放到Codeblocks下编译,死活通不过,至今也不知道原因。两个编程工具都可以编写Arduino程序,只能用哪个编写,就用哪个编译生成。
    11
    | 2018-12-25 13:12 | 只看该作者
    redleaves 发表于 2018-7-8 22:03
    08.    pinMode(Blue.OUTPUT);

    应该是逗号 pinMode(Blue,OUTPUT);

    老大,这你都能马上看出来
    12
    | 2019-1-2 23:12 | 只看该作者
    redleaves 发表于 2018-7-8 22:03
    08.    pinMode(Blue.OUTPUT);

    应该是逗号 pinMode(Blue,OUTPUT);

    大佬 真厉害
    扫描二维码,随时随地手机跟帖
    您需要登录后才可以回帖 登录 | 注册

    本版积分规则

    我要发帖 投诉建议 创建版块 申请版主

    快速回复

    您需要登录后才可以回帖
    登录 | 注册
    高级模式

    论坛热帖

    关闭

    热门推荐上一条 /3 下一条

    快速回复 广东快乐十分走势图 返回列表
  • 女性之声——全国妇联 2019-03-19
  • 【理上网来·辉煌十九大】德国北威州经济部长:十九大报告表明中国有能力为世界做出更多贡献 2019-03-11
  • 全国小麦收获进度过八成 2019-03-07
  • 【人事】中共临汾市委组织部公示3名拟任职干部 2019-03-07
  • 这泼猴,物理。古文,哲学,基础语文,那一项没出丑?看着就想笑 2019-02-20
  • 云南理发店老板涉嫌杀害女演员因办卡纠纷起杀心 2019-02-20
  • 1至5月我区为企业和社会减负4200余万元 2019-02-09
  • 【学习时刻】参会专家盛小云:坚定文化自信,用高尚的作品引领社会风尚 2019-01-28
  • 绘就生态文明新画卷—甘南州造林绿化工作纪实 2019-01-28
  • 某些人总是用“客观事实”来为自己壮胆,实际上根本不懂什么是“客观事实。 2019-01-12
  • 圣洁的雪山文章中国国家地理网 2018-11-22
  • 崇尚英雄 精忠报国——我们家的报国故事 2018-11-22
  • 618史上最壕“买家”现身 Google以 5.5亿美元投资京东 2018-11-21
  • 看好啦!是时候表演真正的技术了 2018-11-21
  • 日本大阪6.1级地震已致4人死亡 370多人受伤 2018-11-20