-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexample.java
29 lines (24 loc) · 950 Bytes
/
example.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import com.pi4j.io.gpio.GpioController;
import com.pi4j.io.gpio.GpioFactory;
import com.pi4j.io.gpio.GpioPinAnalogInput;
import com.pi4j.io.gpio.GpioPinDigitalInput;
import com.pi4j.io.gpio.GpioPinDigitalOutput;
import com.pi4j.io.gpio.PinPullResistance;
import com.pi4j.io.gpio.PinState;
import com.pi4j.io.gpio.RaspiPin;
import com.pi4j.wiringpi.GpioUtil;
public class Example{
final GpioPinDigitalInput pinHXDAT;
final GpioPinDigitalOutput pinHXCLK;
final HX711 hx;
public Example(){
GpioUtil.enableNonPrivilegedAccess();
gpio = GpioFactory.getInstance();
pinHXDAT = gpio.provisionDigitalInputPin(RaspiPin.GPIO_15, "HX_DAT", PinPullResistance.OFF);
pinHXCLK = gpio.provisionDigitalOutputPin(RaspiPin.GPIO_16, "HX_CLK", PinState.LOW);
hx = new HX711(pinHXDAT, pinHXCLK, 128);
hx.read();
System.out.println(hx.value);
System.out.println(hx.weight);
}
}