我找不到问题所在。拼贴、统一码

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

我们正在制作带有五个传感器的键盘,但我们遇到了 mojibake 问题

如果我们点击传感器'a'五次,应该有五个'ㄱ'

但是有类似图片的mojibake。

我们认为这个问题与 unicode 有关,但找不到确切的问题是什么

请回答问题所在。谢谢

#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);
}

您发送的是字节,您发送的确切字节取决于您的编辑器的编码。当您的 capston 应用程序接收到这些字节时,它会尝试根据 capston 的编码来解释它们。不知道它可能是什么。无论如何,您需要做的是从 arduino 发送 utf-8 数据,并确保 capston 应用程序解码 utf-8 数据。