MIT App Inventor 2 + RGB LED strip control

Hello!

I want to create a simple APP using MIT APP Inventor 2, that I´ve already partly developed, to control several components in my car. This is purely to experiment with the Arduino and make a small app. I have already made my first two aspects of the app, but I´m a little stuck at the RGB LED strip function. I´ve created a "screen" inn App Inventor and three sliders that range from 0-255 to control the R, G and B values. How do I want to send these through serial and how do I want to extract these? I´ve seen several examples online, but they don´t really apply to my situation. I have no idea how I want to format these on the APP side and how I want to receive these on the Arduino side. I use a Bluetooth module and this connection is set up already, all I need to find out is how to format the information and send this over the serial communication. Any help would be greatly appreciated. I hope someone can shed some light on the situation and point me in the right direction! Examples would be awesome, as well.

Thank you in advance.
-Frostbite

serial input basics. This might get you started.

Seems like you have all the basics covered.

Mobile app to send out data via serial/bluetooth.
BT module to collect/get sent data and relay to Arduino
Arduino to parse this data ‘do what you need done’ based on the said data.

The serial basics by Robin2 is ‘essential’ as a general overview… (read it) :slight_smile:

Also,… in my footer is a link to a project I played around with a while back… which was using an Adobe Flash aoo I wrote to send data to a PHP script… that sent that via serial/comm port to the Arduino… The arduino then parsed said data, and updated my RGB led to reflect the data sent.

http://forum.arduino.cc/index.php/topic,124394.0.html

you can ignore the Flash & PHP portions… but the Arduino code my give some ideas on how to handle things.

Basically you need a start & end character to let you know when a new piece of data is there and the current one ends…

if I recall… I sent my data/packets as

<r=xxx>
<b=xxx>
<g=xxx>

< start of packet data

of packet data

the r= stuff is to let me know if this is a RED value or GREEN value or BLUE value…etc

good luck!

Hello again and thank you for replies! I've been doing some development, but the serial communications seems to be acting up. It will transmit fine for a couple of turns, but will start acting up after some time and print horrible readings in the serial console. I've added some pictures to show. Also, why is it printing that weird "0" character all of a sudden? Bear in mind that "0dashon" happened right after I reset the Arduino, everything before is prior to a reset.

This is the output and as far as I know all it should print is (RED value GREEN value BLUE value) but it does all kinds of weird stuff. Ignore the "dashon" command as that is from another screen in the app.
I've also included a photo of the app screen itself as an attachment to this reply. Here is the code for that screen:

If you could give me a clue as to why the serial monitor is giving me these weird results and how I could fix them, I think I could get going with exporting the data from the serial comm and storing them on the Arduino as the tutorial showed.
Thanks in advance.
-Frostbite

Screenshot_2016-03-05-18-08-57[1].png

Hello again. After a serious rework on the app and with the help of xl97’s code, I was able to make it work. However, after a while of sending data it will crash. I think it’s when I drag the slider back and forth fast that it just implodes. The app will time out and the arduino won’t respond. What might be causing this? I’m very close to having a system that kind of works thanks to you guys :slight_smile: Any thoughts on my latter problem?
Thanks!
-Frostbite

maybe set the sliders.. then have a button to SEND..

instead of trying to send after each slider movement..

if this works.. might be a timing thing.

Side note:

I have been wanting to get into the MIT App Inventor stuff for a while now.. and just never could 'get it'.. any tips or pointers in that area?

I believe I still have it install on my old netbook.... but was never clear on the 'building block stuff'.. how it works.. what blocks go with what..etc

links or tips/tricks?

xl97:
maybe set the sliders.. then have a button to SEND..

instead of trying to send after each slider movement..

if this works.. might be a timing thing.

Side note:

I have been wanting to get into the MIT App Inventor stuff for a while now.. and just never could 'get it'.. any tips or pointers in that area?

I believe I still have it install on my old netbook.... but was never clear on the 'building block stuff'.. how it works.. what blocks go with what..etc

links or tips/tricks?

Are you suggesting that the Arduino might actually get overloaded and shut down/jam itself? That's a great idea, I will try that. If that works, I'll most likely have to add some sort of delay to prevent this from happening? However, it's very weird that it works flawlessly for a limited period of time! Thanks, I'll try to fiddle with it :slight_smile:

I think the MIT APP Inventor learne curve was rather steep for me aswell, but trust me, when you realize what they all do and how they fit together, you'll have a much easier time. I also have some previous programming knowledge so I guess that helped me a lot. However, I'll provide a link for you that you can follow along with. I'm convinced you will get the hang of it if you see what others create with it and then try to do your own thing. :slight_smile:
I personally used this video to try and understand the MIT APP Inventor. He might be a little hard to understand but he covers a lot of basic stuff and it also applied to what I was trying to do with my APP. There are several videos on YouTube. I personally learn best from videos like this and just trying and failing on my own based off of videos like this. Best of luck and thanks for your help! Keep in mind that the code that he creates is salvageable for other projects, of course!

How to Make MIT app for controlling servo Motor using arduino and bluetooth module.

Thanks.

I too have a (web) programming background.. so hopefully it wont be 'too' difficult. :slight_smile:

I'll check out the link you provided.

appreciate it.