< Return to Video

Talk To Me (part 2), MIT App Inventor Tutorial #2

  • 0:02 - 0:12
    ♩♫♪♬
  • 0:12 - 0:15
    Hi and welcome back to App Inventor's Hour of Code.
  • 0:15 - 0:17
    - I am Emily.
    - And I am Shay.
  • 0:18 - 0:22
    In our last video we showed you how to make the Talk To Me app: You push a button and the phone talks to you.
  • 0:23 - 0:26
    - So cool.
    - Well, we had to start somewhere!
  • 0:26 - 0:28
    I am ready to get to the cool stuff.
  • 0:28 - 0:34
    Okay, now we are going to extend the Talk To me app so that it responds when we shake it and also so the user can input their own text.
  • 0:36 - 0:38
    >Stop shaking me!<
  • 0:38 - 0:44
    - Cool enough for you now?
    - I see endless opportunities. I can go on a run and get constant encouragement.
  • 0:44 - 0:51
    Great! So we are gonna get started and the great thing is, this takes only a couple of minutes because App Inventor makes it really easy.
  • 0:51 - 0:56
    Is your phone talking to you? Well, hang on, because it's about to get even more fun.
  • 0:56 - 1:05
    We left off with our Talk To Me app in the blocks editor. Right now we need to go back into the designer to add another component.
  • 1:05 - 1:13
    We want to extend Talk To Me so that the phone speaks when you shake it. To do that we need an accelerometer component.
  • 1:13 - 1:24
    Click on the sensors drawer and drag out an accelerometer sensor. This is another non-visible component - so it drops down to the bottom of the screen.
  • 1:26 - 1:29
    That's all we need for right now! Go back over to the blocks editor.
  • 1:29 - 1:34
    As you develop your apps you will move back and forth between the designer and the blocks editor quite a bit.
  • 1:36 - 1:41
    We now need a block for when the phone is shaking. This is also called an event handler.
  • 1:41 - 1:46
    Drag out the "when AcceleromenterSensor1.Shaking" block.
  • 1:46 - 1:50
    So, when this event is triggered that's when the phone is being shaken.
  • 1:50 - 1:54
    What do we want to happen then? We want the phone to talk to us, right?
  • 1:54 - 2:01
    So, we already know the blocks that handle that - the same blocks that we have inside the "Button1.Click" event.
  • 2:01 - 2:07
    Here is a cool shortcut that will help you program in App Inventor even more quickly. You can copy and paste blocks.
  • 2:07 - 2:15
    Click on the purple TextToSpeech block. Hit the key combination your computer for copy just like you would do with text.
  • 2:15 - 2:22
    And then hit the key combination for paste. Voilà, you have a new set of the TextToSpeech and text blocks.
  • 2:22 - 2:26
    Drag this new set down into the accelerometer shaking event block.
  • 2:26 - 2:33
    If you had any trouble copying and pasting blocks, that's okay. You can also drag out new blocks from the drawers on the left.
  • 2:33 - 2:42
    Remember, we got the TextToSpeech.Speak block from TextToSpeech and we got the plain text block from the built-in text drawer.
  • 2:43 - 2:49
    So, right now, the phone will speak out loud if you shake it. But wouldn't it be much more fun if the phone says something about been shaken?
  • 2:50 - 2:55
    Let's put in a funny phrase. I am going to type in "Stop Shaking Me!".
  • 2:56 - 2:59
    Okay, try it out! Pick up your phone and shake it.
  • 3:00 - 3:01
    >Stop Shaking Me!<
  • 3:01 - 3:11
    So, our app is pretty cool, right? But wait! There is one more thing to add. Imagine sharing this app with your friends: Don't you think it would be a lot more fun if they can tell the phone what to say?
  • 3:12 - 3:19
    To set this up go back into the designer, go to the user interface drawer and pull out a text box.
  • 3:22 - 3:25
    Let's rearrange that a bit and put the button under the text box.
  • 3:26 - 3:27
    Okay, guess what...
  • 3:28 - 3:29
    Back to the blocks.
  • 3:29 - 3:36
    Click on TextBox1 and look at the blocks it has. We now want to change what happens when the button is clicked.
  • 3:36 - 3:42
    Instead of saying a fixed phrase we want the app to say whatever the user has typed into the text box.
  • 3:42 - 3:52
    Scroll all the way down to the green blocks that we call "getters" and "setters" because they allow you to get and set the properties of the component.
  • 3:52 - 3:59
    You want to get the text that has been typed into the box. So you need the getter block for "TextBox1.Text".
  • 3:59 - 4:03
    Put that block inside the "when Button1.Click" block.
  • 4:03 - 4:12
    To do this you have to throw away the old text block and then click this new TextBox1.Text block in its place.
  • 4:12 - 4:20
    Try your app out again. When you click in the blank text box on your phone your keyboard will come up and you can type in whatever you want.
  • 4:20 - 4:24
    Then, click "Talk To Me" and see what happens.
  • 4:24 - 4:25
    >Hello World<
  • 4:25 - 4:32
    There are some cool ways to extend this app. See the written tutorial for some great ideas for making it even better.
  • 4:32 - 4:37
    If you had any trouble with this tutorial you can view the written version on our website.
  • 4:39 - 4:41
    >Stop! Stop! Stop! Stop!<
    - Aw man, we made a real app!
  • 4:41 - 4:44
    >Stop! Stop! Stop! Stop!<
    - That's kind of annoying!
  • 4:44 - 4:46
    >Stop! Stop! Stop! Stop!<
    - You made it!
  • 4:46 - 4:47
    Oh right.
  • 4:47 - 4:53
    Well you are gonna have a ball with our next step because we're gonna show you how to make a ball roll around the screen when you fling it with your finger.
  • 4:53 - 4:56
    >Stop! Stop! Stop! Stop!<
    - Can't wait!
  • 4:56 - 4:58
    >Stop! Stop! Stop! Stop! Stop! Stop! Stop Shaking Me!<
  • 4:58 - 5:07
    ♩♫♪♬
Title:
Talk To Me (part 2), MIT App Inventor Tutorial #2
Description:

more » « less
Video Language:
English
Duration:
05:11

English subtitles

Revisions