SlideShare a Scribd company logo
TalkToMe Part 2: Shaking and User Input
This tutorial shows you how to extend the basic TalkToMe app so that it responds to shaking, and so
that the user can make the phone say any phrase s/he types in.
Go to App Inventor on the web and log in.
Go to appinventor.mit.edu and click "Create" or log in directly at ai2.appinventor.mit.edu.
TalkToMe Part 2: Shaking and User Input - 1
Open the "TalkToMe" project that you worked on in the last tutorial.
App Inventor will always open the last project you worked on, so you may automatically be taken into
your TalkToMe app.
Go to the Designer Tab
Your project may open in the Designer. If it does not, click "Designer" in the upper right.
TalkToMe Part 2: Shaking and User Input - 2
Add an Accelerometer Sensor
In the Sensors drawer, drag out an AccelerometerSensor component and drop it onto the Viewer. (It's
a non-visible component, so it drops to the bottom of the screen.) NOTE: emulator users should skip
this part and proceed to the next section of this tutorial called "Say Anything". (The emulator can not
respond to shaking!)
TalkToMe Part 2: Shaking and User Input - 3
Go to the Blocks Editor
Click "Blocks" to program the new Accelerometer Sensor that you just added.
Program the Accelerometer Shaking event
Click the AccelerometerSensor1 drawer to see its blocks. Drag out the when
AccelerometerSensor1.Shaking do block and drop it on the workspace.
TalkToMe Part 2: Shaking and User Input - 4
What do we want the app to do when the accelerometer detects shaking?
Copy and paste the blocks that are currently inside the when Button1.Click event handler. You can
select the purple block, then hit the key combination on your computer to copy and then to paste. You'll
have a second set of blocks to put inside the when Accelerometer.Shaking block.
(Alternatively, you can drag out a new call TextToSpeech1.Speak block from the TextToSpeech
drawer, and a new pink text block from the Text drawer.)
Change the phrase that is spoken when the phone is shaking.
Type in something funny for when the phone responds to shaking.
TalkToMe Part 2: Shaking and User Input - 5
Test it out!
You can now shake your phone and it should respond by saying "Stop shaking me!" (or whatever
phrase you put in.)
Say Anything
Is your phone talking to you? Cool! Now let's program the button click so that it causes the phone to
speak whatever phrase the user put into the text box. Go back to the Designer.
TalkToMe Part 2: Shaking and User Input - 6
Add a Text Box to your user interface.
From the User Interface drawer, drag out a TextBox and put it above the Button that is already on the
screen.
Back to the Blocks Editor!
TalkToMe Part 2: Shaking and User Input - 7
Get the text that is typed into the TextBox.
Get the text property of the TextBox1. The green blocks in the TextBox1 drawer are the "getters" and
"setters" for the TextBox1 component. You want your app to speak out loud whatever is currently in the
TextBox1 Text property (i.e. whatever is typed into the text box). Drag out the TextBox1.Text getter
block.
TalkToMe Part 2: Shaking and User Input - 8
Set the Button Click event to speak the text that is in the Text Box.
Pull out the "congratulations..." text box and plug in the TextBox1.Text block. You can throw the pink
text block away by dragging it to the trash in the lower right corner of the workspace.
Test your app!
Now your app has two behaviors: When the button is clicked, it will speak out loud whatever words are
currently in the Text Box on the screen. (if nothing is there, it will say nothing.)
The app will also say "Stop Shaking Me" when the phone is shaken.
TalkToMe Part 2: Shaking and User Input - 9
Congrats! You've built a real app!
Give some thought to what else this app could 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 Speech-To-Text. Have fun!
TalkToMe Part 2: Shaking and User Input - 10

More Related Content

Viewers also liked

low flow flowmeter
low flow flowmeterlow flow flowmeter
low flow flowmeter
永恒 汪
 
La exposición
La exposiciónLa exposición
La exposición
Club Proyecto
 
Universidad fermín toro
Universidad fermín toroUniversidad fermín toro
Universidad fermín toro
Jhonny Javier Jordan
 
Parlamento Juvenil para el Mercosur
Parlamento Juvenil para el MercosurParlamento Juvenil para el Mercosur
Parlamento Juvenil para el Mercosur
Colegio Secundario Buena Vista
 
Act1_GISB
Act1_GISBAct1_GISB
Capturas de pantalla presentación Rodrigo Peñalba
Capturas de pantalla presentación Rodrigo PeñalbaCapturas de pantalla presentación Rodrigo Peñalba
Capturas de pantalla presentación Rodrigo Peñalba
crfonseca
 
Química betzabe rojas
Química betzabe rojasQuímica betzabe rojas
Química betzabe rojas
Betzabe Alejandra Rojas Gutierrez
 
CANER IV | 5 Star Private Gulet Charter | 36 Metres - 6 Cabins – A/C - 12 Gue...
CANER IV | 5 Star Private Gulet Charter | 36 Metres - 6 Cabins – A/C - 12 Gue...CANER IV | 5 Star Private Gulet Charter | 36 Metres - 6 Cabins – A/C - 12 Gue...
CANER IV | 5 Star Private Gulet Charter | 36 Metres - 6 Cabins – A/C - 12 Gue...
THE SJ TRAVEL & YACHTING APPROACH - Gulet charter Bodrum-Turkey
 
Kontent Formaları
Kontent FormalarıKontent Formaları
Kontent Formaları
Qelender Memmedli
 
Sistemas de gestión energética como una herramienta para garantizar la confia...
Sistemas de gestión energética como una herramienta para garantizar la confia...Sistemas de gestión energética como una herramienta para garantizar la confia...
Sistemas de gestión energética como una herramienta para garantizar la confia...
Cámara Colombiana de la Energía
 
Antecedentes de la primera guerra mundial
Antecedentes de la primera  guerra mundialAntecedentes de la primera  guerra mundial
Antecedentes de la primera guerra mundial
Club Proyecto
 
Volúmenes de pirámides y conos
Volúmenes de pirámides y conos Volúmenes de pirámides y conos
Volúmenes de pirámides y conos
Club Proyecto
 

Viewers also liked (12)

low flow flowmeter
low flow flowmeterlow flow flowmeter
low flow flowmeter
 
La exposición
La exposiciónLa exposición
La exposición
 
Universidad fermín toro
Universidad fermín toroUniversidad fermín toro
Universidad fermín toro
 
Parlamento Juvenil para el Mercosur
Parlamento Juvenil para el MercosurParlamento Juvenil para el Mercosur
Parlamento Juvenil para el Mercosur
 
Act1_GISB
Act1_GISBAct1_GISB
Act1_GISB
 
Capturas de pantalla presentación Rodrigo Peñalba
Capturas de pantalla presentación Rodrigo PeñalbaCapturas de pantalla presentación Rodrigo Peñalba
Capturas de pantalla presentación Rodrigo Peñalba
 
Química betzabe rojas
Química betzabe rojasQuímica betzabe rojas
Química betzabe rojas
 
CANER IV | 5 Star Private Gulet Charter | 36 Metres - 6 Cabins – A/C - 12 Gue...
CANER IV | 5 Star Private Gulet Charter | 36 Metres - 6 Cabins – A/C - 12 Gue...CANER IV | 5 Star Private Gulet Charter | 36 Metres - 6 Cabins – A/C - 12 Gue...
CANER IV | 5 Star Private Gulet Charter | 36 Metres - 6 Cabins – A/C - 12 Gue...
 
Kontent Formaları
Kontent FormalarıKontent Formaları
Kontent Formaları
 
Sistemas de gestión energética como una herramienta para garantizar la confia...
Sistemas de gestión energética como una herramienta para garantizar la confia...Sistemas de gestión energética como una herramienta para garantizar la confia...
Sistemas de gestión energética como una herramienta para garantizar la confia...
 
Antecedentes de la primera guerra mundial
Antecedentes de la primera  guerra mundialAntecedentes de la primera  guerra mundial
Antecedentes de la primera guerra mundial
 
Volúmenes de pirámides y conos
Volúmenes de pirámides y conos Volúmenes de pirámides y conos
Volúmenes de pirámides y conos
 

Similar to Talk tomepart2

Appy builder beginner tutorial
Appy builder beginner tutorialAppy builder beginner tutorial
Appy builder beginner tutorial
HabibulHakam
 
Tallerappinventor english
Tallerappinventor englishTallerappinventor english
Tallerappinventor englishlluís nater
 
Taller app inventor english
Taller  app inventor englishTaller  app inventor english
Taller app inventor englishlluís nater
 
I have adream
I have adreamI have adream
I have adream
ANASZ123
 
App Inventor : Getting Started Guide
App Inventor : Getting Started GuideApp Inventor : Getting Started Guide
App Inventor : Getting Started GuideVasilis Drimtzias
 
Lab1
Lab1Lab1
Lab1
rksrks
 
Gui builder
Gui builderGui builder
Gui builderlearnt
 
Mobile Devices Step By Step.
Mobile Devices Step By Step.Mobile Devices Step By Step.
Mobile Devices Step By Step.Jason Wendt
 
Mobile Devices Step By Step.
Mobile Devices Step By Step.Mobile Devices Step By Step.
Mobile Devices Step By Step.Jason Wendt
 
Introducing small basic
Introducing small basicIntroducing small basic
Introducing small basicAn I
 
window_10_user_guide.pdf
window_10_user_guide.pdfwindow_10_user_guide.pdf
window_10_user_guide.pdf
Mertin2
 
Windowstechnicalpreviewqg
WindowstechnicalpreviewqgWindowstechnicalpreviewqg
Windowstechnicalpreviewqg
Alex Carranza
 
Windows 10 Technical Preview - http://f2suporte.blogspot.com
Windows 10 Technical Preview - http://f2suporte.blogspot.comWindows 10 Technical Preview - http://f2suporte.blogspot.com
Windows 10 Technical Preview - http://f2suporte.blogspot.com
Wlademir RS
 
Ios actions and outlets
Ios actions and outletsIos actions and outlets
Ios actions and outlets
veeracynixit
 
Ios actions and outlets
Ios actions and outletsIos actions and outlets
Ios actions and outlets
veeracynixit
 
Tat learning applications en
Tat learning applications enTat learning applications en
Tat learning applications en
Toni Setyawan
 
Zelio soft
Zelio softZelio soft
"Discover windows phone" 05. Application Bar
"Discover windows phone" 05. Application Bar"Discover windows phone" 05. Application Bar
"Discover windows phone" 05. Application BarYasmine Abdelhady
 
Introduction for Windows phone 8.1 .
Introduction for Windows phone 8.1 . Introduction for Windows phone 8.1 .
Introduction for Windows phone 8.1 .
Youssef Elsalhawy
 

Similar to Talk tomepart2 (20)

Appy builder beginner tutorial
Appy builder beginner tutorialAppy builder beginner tutorial
Appy builder beginner tutorial
 
Tallerappinventor english
Tallerappinventor englishTallerappinventor english
Tallerappinventor english
 
Taller app inventor english
Taller  app inventor englishTaller  app inventor english
Taller app inventor english
 
I have adream
I have adreamI have adream
I have adream
 
App Inventor : Getting Started Guide
App Inventor : Getting Started GuideApp Inventor : Getting Started Guide
App Inventor : Getting Started Guide
 
Lab1
Lab1Lab1
Lab1
 
Gui builder
Gui builderGui builder
Gui builder
 
Introduction
IntroductionIntroduction
Introduction
 
Mobile Devices Step By Step.
Mobile Devices Step By Step.Mobile Devices Step By Step.
Mobile Devices Step By Step.
 
Mobile Devices Step By Step.
Mobile Devices Step By Step.Mobile Devices Step By Step.
Mobile Devices Step By Step.
 
Introducing small basic
Introducing small basicIntroducing small basic
Introducing small basic
 
window_10_user_guide.pdf
window_10_user_guide.pdfwindow_10_user_guide.pdf
window_10_user_guide.pdf
 
Windowstechnicalpreviewqg
WindowstechnicalpreviewqgWindowstechnicalpreviewqg
Windowstechnicalpreviewqg
 
Windows 10 Technical Preview - http://f2suporte.blogspot.com
Windows 10 Technical Preview - http://f2suporte.blogspot.comWindows 10 Technical Preview - http://f2suporte.blogspot.com
Windows 10 Technical Preview - http://f2suporte.blogspot.com
 
Ios actions and outlets
Ios actions and outletsIos actions and outlets
Ios actions and outlets
 
Ios actions and outlets
Ios actions and outletsIos actions and outlets
Ios actions and outlets
 
Tat learning applications en
Tat learning applications enTat learning applications en
Tat learning applications en
 
Zelio soft
Zelio softZelio soft
Zelio soft
 
"Discover windows phone" 05. Application Bar
"Discover windows phone" 05. Application Bar"Discover windows phone" 05. Application Bar
"Discover windows phone" 05. Application Bar
 
Introduction for Windows phone 8.1 .
Introduction for Windows phone 8.1 . Introduction for Windows phone 8.1 .
Introduction for Windows phone 8.1 .
 

Recently uploaded

Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)
rosedainty
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
Celine George
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
MIRIAMSALINAS13
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
AzmatAli747758
 
Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
Celine George
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
Fundacja Rozwoju Społeczeństwa Przedsiębiorczego
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
bennyroshan06
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
PedroFerreira53928
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 

Recently uploaded (20)

Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
 
Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 

Talk tomepart2

  • 1. TalkToMe Part 2: Shaking and User Input This tutorial shows you how to extend the basic TalkToMe app so that it responds to shaking, and so that the user can make the phone say any phrase s/he types in. Go to App Inventor on the web and log in. Go to appinventor.mit.edu and click "Create" or log in directly at ai2.appinventor.mit.edu. TalkToMe Part 2: Shaking and User Input - 1
  • 2. Open the "TalkToMe" project that you worked on in the last tutorial. App Inventor will always open the last project you worked on, so you may automatically be taken into your TalkToMe app. Go to the Designer Tab Your project may open in the Designer. If it does not, click "Designer" in the upper right. TalkToMe Part 2: Shaking and User Input - 2
  • 3. Add an Accelerometer Sensor In the Sensors drawer, drag out an AccelerometerSensor component and drop it onto the Viewer. (It's a non-visible component, so it drops to the bottom of the screen.) NOTE: emulator users should skip this part and proceed to the next section of this tutorial called "Say Anything". (The emulator can not respond to shaking!) TalkToMe Part 2: Shaking and User Input - 3
  • 4. Go to the Blocks Editor Click "Blocks" to program the new Accelerometer Sensor that you just added. Program the Accelerometer Shaking event Click the AccelerometerSensor1 drawer to see its blocks. Drag out the when AccelerometerSensor1.Shaking do block and drop it on the workspace. TalkToMe Part 2: Shaking and User Input - 4
  • 5. What do we want the app to do when the accelerometer detects shaking? Copy and paste the blocks that are currently inside the when Button1.Click event handler. You can select the purple block, then hit the key combination on your computer to copy and then to paste. You'll have a second set of blocks to put inside the when Accelerometer.Shaking block. (Alternatively, you can drag out a new call TextToSpeech1.Speak block from the TextToSpeech drawer, and a new pink text block from the Text drawer.) Change the phrase that is spoken when the phone is shaking. Type in something funny for when the phone responds to shaking. TalkToMe Part 2: Shaking and User Input - 5
  • 6. Test it out! You can now shake your phone and it should respond by saying "Stop shaking me!" (or whatever phrase you put in.) Say Anything Is your phone talking to you? Cool! Now let's program the button click so that it causes the phone to speak whatever phrase the user put into the text box. Go back to the Designer. TalkToMe Part 2: Shaking and User Input - 6
  • 7. Add a Text Box to your user interface. From the User Interface drawer, drag out a TextBox and put it above the Button that is already on the screen. Back to the Blocks Editor! TalkToMe Part 2: Shaking and User Input - 7
  • 8. Get the text that is typed into the TextBox. Get the text property of the TextBox1. The green blocks in the TextBox1 drawer are the "getters" and "setters" for the TextBox1 component. You want your app to speak out loud whatever is currently in the TextBox1 Text property (i.e. whatever is typed into the text box). Drag out the TextBox1.Text getter block. TalkToMe Part 2: Shaking and User Input - 8
  • 9. Set the Button Click event to speak the text that is in the Text Box. Pull out the "congratulations..." text box and plug in the TextBox1.Text block. You can throw the pink text block away by dragging it to the trash in the lower right corner of the workspace. Test your app! Now your app has two behaviors: When the button is clicked, it will speak out loud whatever words are currently in the Text Box on the screen. (if nothing is there, it will say nothing.) The app will also say "Stop Shaking Me" when the phone is shaken. TalkToMe Part 2: Shaking and User Input - 9
  • 10. Congrats! You've built a real app! Give some thought to what else this app could 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 Speech-To-Text. Have fun! TalkToMe Part 2: Shaking and User Input - 10