2017년 7월 9일 일요일

Read pinstate arduino script


I'm trying to create an app that can read the status of the Arduino outputs.
I made a button to turn the light on and a button to turn off the light.
If I do the light of the app has to see whether the light really is on (status output)
But how do I get to see this.

Screenshot of the APP and the Arduino script


--
What happens if you try your app?
I think you should add some diagnostics to your app, for example put some (temporary) labels in your design and fill them with responseCode, responseType and responseContent, whenever the Web1.GotText event is triggered. In this way you can find out that something happened and if it is not what you expected, what the problem may be.
Here is a nice tutorial that may help: ESP8266 Controlled with Android App (MIT App Inventor)

The nice thing about App Inventor is that you can try it out of your mind, just as long as it works!

-- 
Have looked at the link and this built in my APP but unfortunately it does not work.
The APP i exported to .aia.
Hope you can see what I'm doing wrong.


-- 
I Will take a look later, but I do not have an ESPxxx so we Will see.
The problem is not that it does not work, no programming job ever works first time, but what the symptoms are and what the app you have really does.

--
I can through the APP or the light on and off, but do not get feedback from the Arduino.Normally goes through "Serial.write" I thought as below
The text of "Serial.write" for example "licht aan" must be labeled "Werkblad_status"


   if(request.indexOf("gpio/1") >0){
      digitalWrite
(2,1);
      
Serial.write("licht aan");
    
}
    
if(request.indexOf("gpio/0") >0){
      digitalWrite
(2,0);
      
Serial.write("licht uit");
    
}

-- 
In the app as you have it now, you just set the URL, so i am amazed that anything happens at all!
In your orginal setup you did Web1.Get and a had a Web1.GotText, now you do not have these, so I am not surprised nothing happens. I am surprised that you can switch your LED's!
So, put in the Web1.Get again and the event block, and do as I said with the debug labels, or you could put in a notifier to see what you received.
In addition I am wondering about your Serial.write(). For a piece of text I would think that you would use Serial.println(). You need the ln part, otherwise the server will think that you will be writing more.

Alternatively, you could try to use the Randomnerd app. It uses a WebViewer component instead of the Web component. Maybe you could also use his sketch at first to see if everything works. And when it does, change it so that you get your nice design back. First make it work and then make it nice is a very good principle in computing.

-- 

댓글 없음:

댓글 쓰기