简体   繁体   English

重载 'write(int)' 的调用不明确

[英]call of overloaded 'write(int)' is ambiguous

Right now, i am trying to print a special character to my LCD screen.现在,我正在尝试在我的 LCD 屏幕上打印一个特殊字符。 for some reason- this message appears: call of overloaded 'write(int)' is ambiguous出于某种原因 - 出现此消息:重载'write(int)'的调用不明确

I have no idea what this means, and help would be great.我不知道这意味着什么,帮助会很大。

Code:代码:

#include <LiquidCrystal.h>

LiquidCrystal lcd(1, 2, 4, 5, 6, 7);

byte customChar[] = {
  B01110,
  B01110,
  B01110,
  B00100,
  B01110,
  B10101,
  B00100,
  B01010
};


void setup() {
  
   lcd.begin(16, 2);
  lcd.createChar(0, customChar);
  lcd.home();
  lcd.write(0);
}

void loop() {
  for(int position = 0; position < 13; position++) {
  lcd.scrollDisplayRight();
  delay(150);

  int state = digitalRead(8);
  if (state != 0) {
    if (state == HIGH) {

    lcd.clear();
    lcd.print("Hello!");
    }
  }
  }
}

Any help?有什么帮助吗?

LiquidCrystal is a subclass of Print which has two write() methods: virtual size_t write(uint8_t); LiquidCrystal 是 Print 的子类,它有两个write()方法: virtual size_t write(uint8_t); and size_t write(const char *str) .size_t write(const char *str) With a parameter of 0 either of those could be called hence it is ambiguous.使用参数 0 可以调用其中任何一个,因此它是模棱两可的。

Try casting to the type you want: write(static_cast<uint8_t>(0))尝试转换为您想要的类型: write(static_cast<uint8_t>(0))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM