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!
https://docs.particle.io/reference/firmware/photon/#input-output
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.
https://docs.particle.io/guide/getting-started/examples/photon/#tinker
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!!!