This depends on how the data from the sensor arrives in your app. Is the temperature data in degrees F, degrees C or what and is it in decimal or hex format.
This link explains a little bit how to use the Math blocks http://www.appinventor.org/ Chapter16
What ever form the data arrives, it needs to be converted into Celcius, Kelvin and Fahrenheit temperatures. There are formulas to make these conversions. Search convert Fahrenheit to Celcius or Centigrate for example.
What exactly have you tried. If you show a screen capture of your blocks it is easier for someone to provide a specific answer.
Can what you want to do be done. Certainly. But you have to know how to use the blocks first ...if you are uncertain, go here:
MITs tutorials http://appinventor.mit.edu/ explore/ai2/tutorials.html
AI2 free online eBook http://appinventor.mit.edu/ explore/ai2/tutorials.html ... the links are at the bottom of the Web page.
And here to learn about Bluetooth with AI2: http://ai2.appinventor.mit. edu/reference/components/
Ok here I leave an screen of the blocks. txtLect is the data that I readed of sensor in degrees Celcius. But the App displays an error saying that the operation math is invalidates. I suspect that may be the data that come with newline (\n), but I do not know if it's these error.
Here are some things to try since I can not test this.
In your global Fahrenheit ... set it to a Math puzzle piece with a value of 0 . In this way, if your query to bluetooth comes back null your Farenhight routine will contain a valid value (zero).
You might need an additional If then block before your call Fahrenheit ... something like if txtLect is a valid number then call Fahrenheit else do nothing. This ensures when the clock interval fires that there is valid data. You might need more error routines; this is a start.
Do you know how to use the AI2 built-in debugger called DoIt. Using it will help you to figure out where the issue is.
Try some blocks. Perhaps someone else will give you more detailed advice; for the moment try the suggested changes. Do the DoIt, post some blocks and ask again if necessary.
댓글 없음:
댓글 쓰기