简体   繁体   English

我找不到什么问题。 莫吉烤,unicode

[英]i can't find what is problem. mojibake, unicode

we're making keyboard with five sensor and we have problem with mojibake我们正在制作带有五个传感器的键盘,但我们遇到了 mojibake 的问题

if we click sensor 'a' five time, there should be five 'ㄱ'如果我们点击传感器'a'五次,应该有五个'ㄱ'

but there are mojibake like attached picture.但是有mojibake像附图。

we think this problem is related with unicode but can't find what the exact probelm is我们认为这个问题与 unicode 有关,但找不到确切的问题

please answer what is problem.请回答是什么问题。 thank you谢谢你

#include <SoftwareSerial.h>
#include<Wire.h>

#define BT_RXD 8
#define BT_TXD 7

SoftwareSerial bluetooth(BT_RXD, BT_TXD);

int SensorPin1 = A0;
int SensorPin2 = A1;
int SensorPin3 = A2;
int SensorPin4 = A3;
int SensorPin5 = A4;

const int MPU_addr=0x68;  
int16_t AcX,AcY,AcZ,Tmp,GyX,GyY,GyZ;

void setup()
{
  Wire.begin();
  Wire.beginTransmission(MPU_addr);
  Wire.write(0x6B);  
  Wire.write(0);     
  Wire.endTransmission(true);
  Serial.begin(9600);
  bluetooth.begin(9600);
}

void loop()
{
  int SensorReading1 = analogRead(SensorPin1);
  int SensorReading2 = analogRead(SensorPin2);
  int SensorReading3 = analogRead(SensorPin3);
  int SensorReading4 = analogRead(SensorPin4);
  int SensorReading5 = analogRead(SensorPin5);

  int FSR1 = map(SensorReading1, 0, 1024, 0, 255);
  int FSR2 = map(SensorReading2, 0, 1024, 0, 255);
  int FSR3 = map(SensorReading3, 0, 1024, 0, 255);
  int FSR4 = map(SensorReading4, 0, 1024, 0, 255);
  int FSR5 = map(SensorReading5, 0, 1024, 0, 255);

  Wire.beginTransmission(MPU_addr);   //-32768~32767
  Wire.write(0x3B);  // starting with register 0x3B (ACCEL_XOUT_H)
  Wire.endTransmission(false);
  Wire.requestFrom(MPU_addr,14,true);  // request a total of 14 registers

  AcX=Wire.read() <<  8|Wire.read();  // 0x3B (ACCEL_XOUT_H) & 0x3C (ACCEL_XOUT_L)    
  AcY=Wire.read() <<  8|Wire.read();  // 0x3D (ACCEL_YOUT_H) & 0x3E (ACCEL_YOUT_L)
  AcZ=Wire.read() <<  8|Wire.read();  // 0x3F (ACCEL_ZOUT_H) & 0x40 (ACCEL_ZOUT_L)
  Tmp=Wire.read() <<  8|Wire.read();  // 0x41 (TEMP_OUT_H) & 0x42 (TEMP_OUT_L)
  GyX=Wire.read() <<  8|Wire.read();  // 0x43 (GYRO_XOUT_H) & 0x44 (GYRO_XOUT_L)
  GyY=Wire.read() <<  8|Wire.read();  // 0x45 (GYRO_YOUT_H) & 0x46 (GYRO_YOUT_L)
  GyZ=Wire.read() <<  8|Wire.read();  // 0x47 (GYRO_ZOUT_H) & 0x48 (GYRO_ZOUT_L)

  Serial.print("AcX = "); Serial.print(AcX);
  Serial.print(" | AcY = "); Serial.print(AcY);
  Serial.print(" | AcZ = "); Serial.println(AcZ);
  //Serial.print(" | Tmp = "); Serial.print(Tmp/340.00+36.53);  //equation for temperature in degrees C from datasheet
  //Serial.print(" | GyX = "); Serial.print(GyX);
  //Serial.print(" | GyY = "); Serial.print(GyY);
  //Serial.print(" | GyZ = "); Serial.println(GyZ);

  if(FSR1 > 100)
  {
    //Serial.println("ㄱ");
    bluetooth.write("ㄱ");
  }

  if(FSR2 > 100)
  {
    //Serial.println("ㄱ");
    bluetooth.write(FSR2);
  }

  if(FSR3 > 100)
  {
    //Serial.println("ㄱ");
  }

  if(FSR4 > 100)
  {
    //Serial.println("2");
  }

  if(FSR5 > 100)
  {
    //Serial.println("ㄱ");
    bluetooth.write("ㄱ");
  }
  if (bluetooth.available()) 
  {
    //Serial.write(bluetooth.read());
  }

  if (Serial.available()) 
  {
    //bluetooth.write(FSR);
  }

  delay(333);
}

在此处输入图像描述

What you are sending is bytes, and the exact bytes you are sending depends on the encoding of your editor.您发送的是字节,您发送的确切字节取决于编辑器的编码。 When your capston application receives those bytes, it tries to interpret them according to the encoding of capston.当您的 capston 应用程序接收到这些字节时,它会尝试根据 capston 的编码来解释它们。 No idea what it might be.不知道它可能是什么。 In any case, what you need to do is to send utf-8 data from the arduino, and ensure that the capston application decodes utf-8 data.无论如何,您需要做的是从 arduino 发送 utf-8 数据,并确保 capston 应用程序解码 utf-8 数据。

暂无
暂无

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

相关问题 我尝试在问题中使用 map 但似乎错误我找不到问题。 你可以帮帮我吗? - I tried to use map in problem but it seems wrong i can t find problem. Could you help me? C++ 无法解决我的问题。 我有控制台错误 - C++ can't solve my problem. I have console error C ++共同祖先问题。 它是什么? - C++ Common Ancestor Problem. What is it? C ++:可能的Xcode(Mac)问题。 无法使用getline()从外部文件中读取数字 - C++: possible Xcode (Mac) problem. Can't read in numbers from external file using getline() Objective C和c ++导入问题。 很简单,但我不明白 - Objective C and c++ import problem. Simple but I don't get it Qt C ++ macOS问题。 我正在使用函数.find(“一个单词”)在multiset中搜索单词,它可以在Windows上运行,但不能在mac上运行 - Qt C++ macOS problem. I am searching for words in multiset with function .find(“a word”) it works on windows but not on mac 提交 Kattis “OddGnome”问题时出错。 我在本地得到正确的输出,我的代码有什么问题? C++ - Getting error on submission for Kattis "OddGnome" problem. I am getting the right output locally, what is wrong with my code? C++ ACM问题。 我的代码有什么问题? - A acm problem. What's wrong in my code? 十六进制计算器问题。 有人可以再次检查我的代码吗? - Hexa Calculator Problem. Can someone check my code again? 我不确定这个问题上的几件事。 - I'm not sure about a few things on this problem.
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM