Hmm… First of all, i made a mistake in the last Code. The last accelerator.class should be Accelerometer.class.
As for the error… maybe try replacing Native.loadLibrary() with Native.load(); Apparently loadLibrary() works only if the .dll file is in the correct path (from where libraries are loaded for JNA), while load can take any path to load the libraries…
If that doesn‘t work, we‘ll have to redefine the Systems property „jna.path.library“ with the commandline… which in turn means starting the sketch with the cmd (commandline) and that would just make it annoying to start up each time…
The problem is that the System.setProperty() function is probably too Late to call in the Code. We‘ll have to call it before, and for that we need to call it in the cmd like this :
java -Djna.library.path=<path to your library> MainClass
Now the problem is, to start a Processing sketch, the Code is :
As you can see, the to run a java class and running it with the new path property is pretty easy to figure out.
The problem is that i have no idea, where (or if) we can include the -Djna.library.path= part…
This is pretty much the same as saying processing-java is equal to java, -D…> stays the same and then —sketch…—run is equal to MainClass.
But i‘m not good with the cmd, so that might as well be nonsense…
So if that doesn‘t work, we‘ll have to export your current sketch and just call it like a normal java class (which should hopefully be easier)…
Does the microsoft sample work for you? If so, you could probably do that, yes. But we’ll have to see how to inform the running processing sketch of a change (either by updating a variable constantly, or better, call a function within the running sketch).
I‘ve looked around a bit and most refer to JNI to do this (more complex version of JNA), but apparently there‘s also a way to do this with System.Diagnostics.Process.
As for how that works, i‘ll take a look at the Documentation. But it seems to be a lot easier.
I think another approach would be a lot easier. We could send a variable to your arduino with Serial through the Port in C# (in the sample Code) and from the arduino to processing. That would be a lot easier.
But before i try to get the Code together, please tell me if that approach would work out for you.
My app is taking to arduino via serial.
I thought about creating file when accelerometer is kicked and in Processing I would check if file exist. If exist produce beep.
not most elegant, but within my knowledge.
It would probably be more elegant to write the first line with C# in the .txt and read that from processing. This way you could actually establish a simple two way communication.