Hour of Code

Welcome to the MIT App Inventor Hour of Code!

Are you ready to build your first mobile app with MIT App Inventor? the components window In this hour, we will build an app that talks to you!

You first need to set up your computer to be able to run your app, so first click on the "Set up your Computer" tab below and follow the instructions. Then you should continue with the "Talk to Me" tab to make the app.

hAPPy Inventing!

Set up your Computer

Talk To Me

Introduction to Environment

There are two main components to the App Inventor environment: the Designer and the Blocks Editor.

The Designer allows you to add components to your app and lay out what it will look like.

designer window

The Blocks Editor allows you to code your app to give it functionality--that is, make it do stuff!

blocks editor window

You can toggle between the two screens using the buttons in the top right corner.

switching between designer and blocks editor

Designer Components

Within the Designer, there are five windows: Palette, Viewer, Components, Media, and Properties.

The Palette is where all available components are. You can drag and drop any component from the Palette into the Viewer.

the palette window

The Viewer is where you can see what the app will look like and is where you drag components.

the viewer window

The Components window shows all components that have been added to the app. Note that the Screen component is automatically listed as a component.

the components window

The Media window shows any uploaded media files, like images and sounds.

the media window

Finally, the Properties window allows you to view or change any of the properties (or characteristics) of the currently selected component.

the properties window

Add a Button

In the designer, add a Button component.

the components window

If you have your device connected, or emulator running, you should see your button appear.

Now change the Text property for Button1 to "Talk to Me".

the components window

Add a TextToSpeech component

Now add another component, TextToSpeech , which is in the Media drawer.

the components window

And that's it for the components! Now switch to the Blocks editor.

the components window

Code the Button.Click event

In the Blocks Editor, you will choose Button1, and drag in a Button1.Click event block.

the components window

Now drop in a TextToSpeech.Speak block into the Button1.Click event block.

the components window

Tell the app what to say

The last part is dragging a text block to the message field to tell the app what to say. From the Text drawer, drag in a blank text block and snap it to the TextToSpeech.Speak block.

the components window

Now change the text block to what you want the app to say. How about "Congratulations, you made your first app!".

the components window

Test your app

Now you can test your app. Let's assume that you have connected your phone or tablet, or have the emulator running in your browser. If you haven't done so, click on the "Set up your Computer" tab above to set up your computer to test your app.

If you are not currently connected, got to the Connect menu and select your chosen method of connection (Companion, emulator, or USB).

connect menu

The video shows how it works on a phone, but you can also click the button in the emulator .

the components window

What's next?

Follow the Talk to Me Part 2 tutorial on the next tab to add some more fun features to your app.

the components window

You've done a great job on this app! If you want to stop at this point, click here for your Hour of Code certificate!


Talk To Me Part 2

Add new features to Talk to Me

We will add shaking and variable text in Part 2.

the components window

Add the Accelerometer Sensor

Go back to the Designer window, and drag in an Accelerometer component from the Sensors drawer.

the components window

Accelerometer.Shaking block

Back in the Blocks Editor, drag out an Accelerometer1.Shaking block.

Note: If you are working with the emulator, this code will not be able to be tested, because you can't shake your computer!

the components window

Copy and paste the TextToSpeech.Speak block from the Button1.Click event block, and snap it into the Accelerometer1.Shaking event block. the components window

Change the text block to say something different when the phone is shaken. Something like "Stop shaking me!". the components window

Test the app

If you are using a phone or tablet, try shaking the phone!

the components window

Add a TextBox

Go back to the Designer, and drag a TextBox into the Viewer. Then move Button1 below the TextBox .

the components window

Speak what is in the Textbox

Go back to the Blocks Editor. Then drag out a TextBox1.Text block and replace the "Congratulations" text block in the Button1.Click event block with the new block.

the components window

Test the App

Try typing something in the textbox in your app. You can do this whether you are using the Emulator or a phone or tablet.

the components window

Congratulations! You've built a talking app. You're an App Inventor!

Click here for your Hour of Code certificate!


Expand your app

Add more features to your app!

Now that you've made your Talk to Me app, what else this app could this app do? Here are some ideas for extensions:
  • Random phrase generator
  • Mad Libs - player chooses noun, verb, adjective, adverb, person and it picks one from a list that you program
  • Magic 8 Ball App
  • Name picker - useful for teachers to call on a student
  • You could also play around with the Speech-To-Text component.

Have fun!