简体   繁体   中英

PI4j Raspberry Pi Infrared receiver

I have connected a Infrared receiver to Rasberry Pi like this: 在此处输入图片说明

And i have tried the example from URL: http://pi4j.com/example/listener.html to get information from the GPIO 18 but it outputs nothing into terminal.

Is there any way i can get info from infrared receiver in Java with Pi4j.

I know that the Python script exists but i want to learn if there is possibility to read sensors data from Java.

UPDATE 1:

GPIO port 18 is port 1 in Pi4j now i get the output with states LOW HIGH how can i now decode the signal so i can use it for transmitter.

If you are able to read HIGH and LOW from the sensor, to decode the signal you need to time the lapses between those states, to be able to recognize different signals. Of course, that can be done in Java, for instance using System.nanoTime() for precise timing.

There is a good tutorial on how to do this in Adafruit , in particular read from this section on. It is not in Java (it is for Arduino), but the idea can be easily adapted to use Pi4J.

Try using jlirc . It uses lirc package on linux. Install lirc package on your raspberry pi and have it running.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM