带有hx711库的Arduio不起作用

时间:2016-12-13 18:34:14

标签: bluetooth arduino

使用amplifir hx711访问体重秤传感器的代码需要使用hx711.h库。当我将它包含在我的代码中时,我看到了这个错误:

  

proj0:25:错误:空字符常量   
发送='';   
^

     

proj0:10:错误:'hx711'没有命名类型   
hx711 scale(out,clk);   
^

     

proj0:11:错误:'hx711'没有命名类型   
hx711 scale1(A2,A3);   
^

     

C:\ Users \ ramadan \ Desktop \ proj0 \ proj0.ino:在函数'int readsensor(char)'中:

     

proj0:37:错误:此范围内未声明“scale”   
案例'1':scale.set_gain(64);   
^

     

退出状态1   
空字符常量

#include <hx711.h>

#include <SoftwareSerial.h>
#define out A0
#define clk A1
int bluetoothTx =3;
int bluetoothRx =4;

SoftwareSerial bluetooth(bluetoothTx, bluetoothRx);
hx711 scale(out,clk);
hx711 scale1(A2,A3);
void setup() {
 // setupBlueToothConnection(); //Used to initialise the Bluetooth shield
   pinMode(bluetoothTx, INPUT);
  pinMode(bluetoothRx, OUTPUT);
//setupBlueToothConnect
  bluetooth.begin(38400);
}

void loop() {
  //Read from bluetooth and write to usb serial
  if(bluetooth.available()) {
  char toSend = (char)bluetooth.read();
    long x=readsensor(toSend);
    toSend='';
    if(x>0){

      bluetooth.print(x);
      }
  }
  delay(500);

}
int readsensor(char s){
  long y=0;
    switch(s){
       case '1':scale.set_gain(64);
      y=scale.read();
       break;
       case '2':scale.set_gain(32);
        y=scale.read();
       break;
       case '3':scale.set_gain(64);
      y=scale.read();
       break;
       case '4':scale.set_gain(32);
        y=scale.read();
       break;
      default:break;
      }
      return y;
  }
 /* void setupBlueToothConnection()
{
blueToothSerial.begin(9600);// BluetoothBee BaudRate to default baud rate 38400
//blueToothSerial.print("\r\n+STWMOD=0\r\n"); //set the bluetooth work in slave mode
blueToothSerial.print("\r\n+STNA=HC-05\r\n"); //set the bluetooth name as "SeeedBTSlave"
blueToothSerial.print("\r\n+STOAUT=1\r\n"); // Permit Paired device to connect me
blueToothSerial.print("\r\n+STAUTO=0\r\n"); // Auto-connection should be forbidden here
delay(2000); // This delay is required.
blueToothSerial.print("\r\n+INQ=1\r\n"); //make the slave bluetooth inquirable 
//Serial.println("The slave bluetooth is inquirable!");
delay(2000); // This delay is required.
blueToothSerial.flush();
}*/

0 个答案:

没有答案