What are the arguments should be put into callfunction() when I want to use digitalread or digital write by java in an android project
@Gilbert_Dwyane, referring to the documentation will save you a lot of time and make things easier!
Sorry I forget to mention I am using java to make an android app
thx for the reply, however I have tried this code in my app, apparently it does not work and the return value is -2, I don’t know what does it suppose to mean. Do you have more clear ideas about it? I have already tried to use the example provided in the api, however it does not work and this function returns a value of -2.Does anyone have any idea what does this -2 supposed to mean? Thx
It’s not by any chance the return value programmed in your device for that function?
Seeing some code would help.
this is how I implement the function.
If I change the “1” to “HIGH”, the return value will become to 1 but the voltage of the pin D1 staill remain unchanged
I was hoping to see the code on your device as well.
Furthermore, if you’re posting code, then please copy&paste it, since we really don’t want to re-type everything if we want to give it a shot. Mind the code formatting when you’re doing that though.
you can basically refer to the repository here. I use the same one but just make little changes which already shown in the screenshot just now I have posted
That’s just the android SDK…
I’d like to see the code on the device, the Particle Device. Your photon, electron, bluz, duo, Core, Pi. Anything but that android code.
If the code on the device isn’t meant to work together with the arguments you’re sending, you could be seeing these ‘errors’, which may in fact be the valid response.
I am sorry but what do you mean by “code on the device”, I am connecting my photon with the tinker app on my iphone. While I create the android app above wanna to change the value of a certain pin. I am a bit confused by “the device” you refer to. There is not any code I need to load into the photon right? Sorry for my dumb question
Normally you would change the code on the photon to do the things you want it to do. Unless you’ve done that, it’s running a ‘demo’ application, also called ‘tinker’. That exposes the functions you’re trying to call.
-2 is a valid output if the input you’ve given it is incorrect. For digitalwrite it needs either “HIGH” or “LOW”. Anything else will give you the -2.
Take a look in the docs at the Tinker code to see when it does what.
thx for the advice, I just realized i need to set a high pin and a low pin in order to light up an led. At first I only use a high pin, which will definitely not work but the function is already there. Thx anyway!!!