Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/arduino/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在用C编写Arduino程序时,如何将两个字符相邻地写入?_Arduino_Lcd_Adafruit_Arduino C++ - Fatal编程技术网

在用C编写Arduino程序时,如何将两个字符相邻地写入?

在用C编写Arduino程序时,如何将两个字符相邻地写入?,arduino,lcd,adafruit,arduino-c++,Arduino,Lcd,Adafruit,Arduino C++,我的arduino有以下代码,但是adafruit lcd显示屏只打印向下箭头字符,而不是向上箭头,然后是向下箭头。(循环函数是空的,所以我没有包含它) #包括 #包括 #包括 Adafruit_RGBLCDShield lcd=Adafruit_RGBLCDShield(); #定义向上箭头0 字节up[]={4,14,31,4,4,4,0,0}; #定义向下箭头1 字节向下[]={0,0,4,4,4,31,14,4}; 无效设置(){ lcd.clear(); lcd.begin(16,2)

我的arduino有以下代码,但是adafruit lcd显示屏只打印向下箭头字符,而不是向上箭头,然后是向下箭头。(循环函数是空的,所以我没有包含它)

#包括
#包括
#包括
Adafruit_RGBLCDShield lcd=Adafruit_RGBLCDShield();
#定义向上箭头0
字节up[]={4,14,31,4,4,4,0,0};
#定义向下箭头1
字节向下[]={0,0,4,4,4,31,14,4};
无效设置(){
lcd.clear();
lcd.begin(16,2);
lcd.setCursor(0,0);
lcd.createChar(向上箭头,向上);
lcd.写入(向上箭头);
lcd.setCursor(1,0);
lcd.createChar(向下箭头,向下);
lcd.写入(向下箭头);
}

基于库的源代码

void Adafruit_RGBLCDShield::createChar(uint8_t location, uint8_t charmap[]) {
  location &= 0x7; // we only have 8 locations 0-7
  command(LCD_SETCGRAMADDR | (location << 3));
  for (int i=0; i<8; i++) {
    write(charmap[i]);
  }
  command(LCD_SETDDRAMADDR);  // unfortunately resets the location to 0,0
}
void Adafruit\u RGBLCDShield::createChar(uint8\u t位置,uint8\u t字符映射[]){
位置&=0x7;//我们只有8个位置0-7

命令(LCD_SETCGRAMADDR |)(位置基于库的源代码

void Adafruit_RGBLCDShield::createChar(uint8_t location, uint8_t charmap[]) {
  location &= 0x7; // we only have 8 locations 0-7
  command(LCD_SETCGRAMADDR | (location << 3));
  for (int i=0; i<8; i++) {
    write(charmap[i]);
  }
  command(LCD_SETDDRAMADDR);  // unfortunately resets the location to 0,0
}
void Adafruit\u RGBLCDShield::createChar(uint8\u t位置,uint8\u t字符映射[]){
位置&=0x7;//我们只有8个位置0-7
命令(LCD_SETCGRAMADDR |)(位置来自:

注意:当引用自定义字符“0”时,如果它不在变量中,则需要将其转换为字节,否则编译器将抛出错误。请参见下面的示例

在您的示例中,
lcd.write(向上箭头);

可以尝试:
lcd.write(字节(向上箭头));

希望有帮助。

来自:

注意:当引用自定义字符“0”时,如果它不在变量中,则需要将其转换为字节,否则编译器将抛出错误。请参见下面的示例

在您的示例中,
lcd.write(向上箭头);

可以尝试:
lcd.write(字节(向上箭头));


希望有帮助。

我的问题是,创建一个字符会将光标位置重置为(0,0),因此当我将光标设置为(0,1)并创建向下箭头时,它会将光标重置为(0,0)。我的解决方案是先创建自定义字符,然后设置光标并写入它们。

我的问题是创建字符会将光标位置重置为(0,0),因此当我将光标设置为(0,1)并创建向下箭头时,会将光标重置为(0,0)。我的解决方案是先创建自定义字符,然后设置光标并写入它们