2

My code to access weight scale sensor using amplifir hx711 require using hx711.h library. When I include it in my code I see this errors:

proj0:25: error: empty character constant
toSend='';
^

proj0:10: error: 'hx711' does not name a type
hx711 scale(out,clk);
^

proj0:11: error: 'hx711' does not name a type
hx711 scale1(A2,A3);
^

C:\Users\ramadan\Desktop\proj0\proj0.ino: In function 'int readsensor(char)':

proj0:37: error: 'scale' was not declared in this scope
case '1':scale.set_gain(64);
^

exit status 1
empty character constant

#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();
}*/
jrbedard
  • 3,662
  • 5
  • 30
  • 34

0 Answers0