Skip to first unread message

K Lazaro

unread,
Feb 20, 2019, 1:53:55 AM2/20/19
to mitappinv...@googlegroups.com
Hello, everyone!

I am working on a project, and my goal is to send a string command from app inventor to arduino via bluetooth to control a dc motor. There are available applications and examples on how to control a dc motor using buttons "ON" and "OFF" in android. But in this project, I need to be able to control a dc motor using text strings.

For example, when I input "abc" in the textbox and click "Print", the dc motor connected to arduino should: rotate clockwise, stop (x sec, x = depends on delay time), rotate counterclockwise, stop (x sec), stop, stop (x sec)

Note: a = clockwise
b = counterclockwise
c = stop

What I did in my app inventor code is this:
Input a set of strings (say, a paragraph) inside the textbox.
Then, when "Okay" button is clicked, it will process the text inside the textbox and split each letter into a list.
After that, I wanted to check if it actually appears in list form, so I printed the results into the spinner.(optional)

I need to send the data from the list, one at a time, to arduino via bluetooth. How do I do that? This approach of mine isn't working the way I expect it to do..


Thanks a lot! Any help would be highly appreciated!

Screen1.PNG
blocks.PNG

TimAI2

unread,
Feb 20, 2019, 11:33:07 AM2/20/19
to MIT App Inventor Forum
Use a counter (global variable) and length of list
Add 1 to the counter each time the clock fires
The clock interval needs to be long enough for the actions called to complete

ABG

unread,
Feb 20, 2019, 11:57:41 AM2/20/19
to MIT App Inventor Forum
For an example of how to use a Clock Timer to drive
serial time output from a list of codes, see my Morse Code sample,

The general idea is to have the Clock Timer service item 1 of the output list,
deleting it after it has been serviced to allow the next step to roll up,
like a slow machine gun.

ABG

Reply all
Reply to author
Forward
0 new messages