This tutorial will show you that you can use signals from your car to trigger other events in an android application.
This is an application that will automatically send you a text when you turn off your car if your fuel level is below a certain percentage.
|Component Type||Palette Group||What You'll Name It||Purpose of Component||Component Settings|
|Label||User Interface||FuelLevelLabel||This label's text will update whenver the car's fuel level changes||FontSize:20|
|Vertical Arrangement||Layout||VerticalArrangement1||Used to center the label||AlignHorizontal:Center, AlignVertical:Center, Height:400px|
|OpenXC||Sensors||OpenXC1||This component gives you access to the car's data|
|Texting||Social||Texting1||This is what allows the application to send the automatic text message|
First, we're going to build the the block that causes the FuelLevelLabel to update whenever the car's fuel level changes.
At this point, the label should give real time feedback about the car's fuel level. If you ave your android device hooked up to the vehicle simulator or to a car, then you should be able to see the text change when the car's fuel level changes.
Now, we're going to build the block that automatically sends the text message. When the car's ignition status changes, the application will check to make sure that the car is off and that the fuel percentage is below the number you specify. In the picture below, the number is set to .2 but you're free to set the value to whatever you'd like as long it's it's between 0 and 1.
Here's a screenshot of the completed application. Now, if the application is running, your phone will automatically text you when you turn the car off if your gas is too low.
Based on what you've learned here, you can modify the application to let someone know that you made it to your destination safely. Try adding a block that sends a text message to someone else when your car turns off.
If you'd like to work with this sample in App Inventor, download the source code ? (make this a hyperlink) to your computer, then open App Inventor, go to the My Projects page, and choose More Actions | Upload Source.