BS1USB to Java
Edje09
Posts: 2
I recently started using my BS1USB and I had a question about using output with other programming languages. I've attached a hall effect sensor and wrote the code below. Basically, the code loops every 10 units of time and checks the state of the sensor. If the sensor is "off" (no magnet within range), debug returns 0. If the sensor is "on" (magnet within range), it returns 1.
What I'm trying to do, in part, is build a bike computer. I'd like to write a program in another language (probably Java, since that's really all I'm comfortable coding with at the moment) that monitors the debug output from the BS1USB and performs calculations based on the frequency of outputs to determine how fast the wheel (with attached magnet) is spinning. I also want to use that information to drive a video.
I realize the above code is not very elegant, and it has a pretty low fidelity since it's dependent on the time set for loop. If anyone has a more elegant solution (like an event listener to determine precisely when an output is sent), I'd love to hear it, but my primary question is regarding the output to other languages.
Thanks in advance!
Main:
IF PORT => 0 THEN Win
'GOSUB Main
Win:
DEBUG CLS
DEBUG PORT
PAUSE 10
GOSUB Main
What I'm trying to do, in part, is build a bike computer. I'd like to write a program in another language (probably Java, since that's really all I'm comfortable coding with at the moment) that monitors the debug output from the BS1USB and performs calculations based on the frequency of outputs to determine how fast the wheel (with attached magnet) is spinning. I also want to use that information to drive a video.
I realize the above code is not very elegant, and it has a pretty low fidelity since it's dependent on the time set for loop. If anyone has a more elegant solution (like an event listener to determine precisely when an output is sent), I'd love to hear it, but my primary question is regarding the output to other languages.
Thanks in advance!
Comments
2) The DEBUG output is complex. The Nuts and Volts Column #20 discusses the DEBUG data format. You should be able to write a Java program to extract what you need.
Main:
IF PORT => 0 THEN Win
GOTO Main
Win:
DEBUG CLS
DEBUG PORT
PAUSE 10
GOTO Main