极客工坊

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 16589|回复: 1

Arduino编译报错‘fatal error: WConstants.h: No such file or directory’

[复制链接]
发表于 2018-11-19 21:26:10 | 显示全部楼层 |阅读模式
本帖最后由 弘毅 于 2018-11-20 09:13 编辑

Arduino编译报错‘fatal error: WConstants.h: No such file or directory’ 该如何解决。按照网上的放发试过更新两个库函数还是没有用,而且只是个1602显示屏自带的测试程序,而且也没见调用过OneWire和DallasTemper两个函数呀,换了另外一个程序也是一样报这个错误 我该怎样处理?谢谢!!



  1. //example use of LCD4Bit_mod library
  2. #include <LCD4Bit_mod.h>
  3. //create object to control an LCD.  
  4. //number of lines in display=1
  5. LCD4Bit_mod lcd = LCD4Bit_mod(2);

  6. //Key message
  7. char msgs[5][15] = {"Right Key OK ",
  8.                     "Up Key OK    ",
  9.                     "Down Key OK  ",
  10.                     "Left Key OK  ",
  11.                     "Select Key OK" };
  12. int  adc_key_val[5] ={30, 150, 360, 535, 760 };
  13. int NUM_KEYS = 5;
  14. int adc_key_in;
  15. int key=-1;
  16. int oldkey=-1;

  17. void setup() {
  18.   pinMode(13, OUTPUT);  //we'll use the debug LED to output a heartbeat

  19.   lcd.init();
  20.   //optionally, now set up our application-specific display settings, overriding whatever the lcd did in lcd.init()
  21.   //lcd.commandWrite(0x0F);//cursor on, display on, blink on.  (nasty!)
  22.    lcd.clear();
  23.   lcd.printIn("KEYPAD testing... pressing");
  24.    
  25. }

  26. void loop() {

  27.   adc_key_in = analogRead(0);    // read the value from the sensor  
  28.   digitalWrite(13, HIGH);  
  29.   key = get_key(adc_key_in);            // convert into key press
  30.   
  31.   if (key != oldkey)            // if keypress is detected
  32.   {
  33.     delay(50);    // wait for debounce time
  34.     adc_key_in = analogRead(0);    // read the value from the sensor  
  35.     key = get_key(adc_key_in);            // convert into key press
  36.     if (key != oldkey)        
  37.     {     
  38.       oldkey = key;
  39.       if (key >=0){
  40.       lcd.cursorTo(2, 0);  //line=2, x=0
  41.         lcd.printIn(msgs[key]);
  42.       }
  43.     }
  44.   }
  45.   
  46.   //delay(1000);
  47.   digitalWrite(13, LOW);
  48. }

  49. // Convert ADC value to key number
  50. int get_key(unsigned int input)
  51. {
  52.   int k;
  53.    
  54.   for (k = 0; k < NUM_KEYS; k++)
  55.   {
  56.     if (input < adc_key_val[k])
  57.     {
  58.            
  59.     return k;
  60.         }
  61.   }
  62.    
  63.     if (k >= NUM_KEYS)
  64.         k = -1;     // No valid key pressed
  65.    
  66. return k;
  67. }
复制代码

回复

使用道具 举报

发表于 2018-11-20 15:13:44 | 显示全部楼层
需要把原来放进去的库,删除之后重新放一遍,需要更新的是这个文件的库#include <LCD4Bit_mod.h>
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则 需要先绑定手机号

Archiver|联系我们|极客工坊

GMT+8, 2024-4-26 00:59 , Processed in 0.039909 second(s), 18 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2021, Tencent Cloud.

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