I can not get the value from the firebase

Hi, i want to get data (0 or 1) whereas led2 on or off to my Label3. Here is my firebase and block diagram:


I can change the value of led2 from my arduino circuit and firebase takes it but i dont know how i can take the value with the block diagrams to Label 3.

Your FireBase.GotValue event needs an extra if/then test block to see if the tag is "led" versus "led2", to let it know which label(s) to update from the incoming value.

Fit one if/then inside the other if/then.

Thanks, i fixed the problem but i started a new proteject. I wrote the conditions in a paper given below and mit app invertor. I can get the button values and turn the leds on but the conditions are not worked. How can i fix multiple conditions?

You are missing an if/then/elseif/elseif/elseif ladder to test a lot of different combinations.

You can build one using the blue mutator button in the if/then block.

https://appinventor.mit.edu/explore/ai2/support/concepts/mutators

Please download and post each of those event block(s)/procedures here ...
(sample video)

I did like that


But they dont work when conditions change, it can not use the values coming. Also, can it perceive which bits belong to which tag? I tried to make it with "logic and blocks" but i am not sure.

It works only this condition:


But they can do only 1 process. I can't combine other conditions.

You are getting closer to a solution.

  • if tag = this then
    • if value = 1 then
      • do that
    • else
      • do something else
  • else if tag = othertag then
    • if value = 1 then
      • do who knows what
    • else
      • do I don't know

I did something like that:


But it didnt work. I want to compare values of texts (kapi_acik and kapi_kapali).
If kapi_kapali = 0 and kapi_acik = 0, print ARADA
If kapi_kapali = 0 and kapi_acik = 1, print KAPI AÇIK
If kapi_kapali = 1 and kapi_acik = 0, print KAPI KAPALI
If kapi_kapali = 1 and kapi_acik = 1, print ARIZA!
So i need to get values of text and compare them, but for if else, i can compare for only KAPI AÇIK and KAPI KAPALI like that:

Hee is the structure you need.

Fill in the 4 empty parts with the appropriate text and color settings.
(Draggable)

It didnt work for me. I need to compare values of kapi_acik and kapi_kapali in same if section. I specified conditions before your answer, could you look at 8/9 line?

You did not show how you filled in the empty parts in my sample.

Please be aware that the DataChanged event does not always receive notification of data changed from an Arduino. The AI2-Firebase connection needs to be 'woken up' by a prior communication with Firebase. (@TimAI2 is more expert at this than me, and I do not have a good reference for this in my Firebase FAQ.) To confirm that you actually received any sort of Data Changed event, you might pop up a Notifier or increment a Label.Text value. That would help to distinguish between No DataChanged Event Received and DataChanged Misinterpreted.

Lastly, in your code you are not thinking through the effects of having passed an if/then test on a piece of data. If you pass the if test, you will execute the code in the THEN socket. You tested a tag to see if it contains a particular piece of text. If that test succeeded, how is it possible for that tag to also be a different value within that piece of code? A tag or variable can't have two values at the same time, right?
7ad76fe22cde7d7082d17b4df9d7becac3ac7fac_2_422x500

I fill like that:


As i said, i need to compare both values for 00,01,10,11 conditions. The conditions are connected to each other. So i can not use values seperately.

I suggest you read
http://www.appinventor.org/bookChapters/chapter18.pdf
from

Thanks sir for your helping, i'll check it now.

In the interest of being able to test your logic independently of a Firebase connection, I suggest adding a section to your display with these 3 components:

  • a Textbox txbTag showing the tag
  • a Textbox txbValue showing the associated value
  • a Button btnEnter with a Click event to apply your logic to the .Text contents of the two Textboxes

This will let you test your logic without having to worry about listening to Firebase.

Is there any function for getting value of the text? For example, i want to test of value of X,
If "valueofX" = 1 do ... . Because if i compare values of texts logically like
If valueOf"kapi_acik" && valueOf"kapi_kapali" == 1 do print "ARIZALI!" i will get exactly what i want.

Are you asking about dictionaries?
http://ai2.appinventor.mit.edu/reference/blocks/dictionaries.html
Or are you asking about variables?

I dont know but, I want to get the value which text in firebase. For example, if "kapiyi_ac" is 1 on firebase, i want to get 1 with using text name. If i can get it, i can compare in and block two different firebase values mathematically using text names.

It is something like that :
image
He/she did it with variables but i want it with texts like "kapiyi_ac".

Use a dictionary, with your tags for keys, and the values from the incoming Firebase values associated with those tags.