Introduction 1
About This Book 1
Foolish Assumptions 2
Icons Used in This Book 3
Beyond the Book 4
Where to Go from Here 4
Part 1: Getting Started 5
Chapter 1: What Is Coding? 7
What Languages Will I Use? 8
What Does a Computer Program Look Like? 9
A Hello World! Example 10
Recipe for a Program 11
Planning a Program 13
Prepping Yourself to Code 15
Coding Cool Stuff 16
Chapter 2: Working with Programming Languages and IDEs 18
Basic IDE Setup and Navigation 19
Adding Hardware 33
Getting Fancier with User Interfaces 36
Chapter 3: When Things Go Wrong 40
Syntax Errors 41
Logic Errors 42
Debugging Scratch Programs 43
Debugging App Lab Programs 45
Debugging MakeCode Programs 49
Commenting Out Code when Debugging 51
Part 2: Sounds, Color, Random Surprises 53
Chapter 4: Orchestra 55
Brainstorm 56
Sidebar: Event-driven programming 56
Start a New Project 57
Add a Backdrop 58
Add Instrument Sprites 59
Add a Singer Sprite and Modify Its Costume 61
Code Each Instrument to Play a Sound 63
Sidebar: Parallel processing 67
Save, Test, and Debug Your Program 67
Share Your Program with the World 68
Enhance Your Toy 68
Chapter 5: Foley Sound Generator 69
Brainstorm 69
Sidebar: User Interfaces 70
Start a New Project 71
Add a Background 72
Add Sound and Stop Sounds Buttons 75
Code the Sound Buttons to Play 78
Code the Stop Sounds Button to Stop Sounds 80
Save, Test, and Debug Your App 82
Share Your App with the World 82
Enhance Your App 82
Chapter 6: Lucky Numbers 83
Brainstorm 84
Start a New Project 85
Code Button A 85
Sidebar: Coding Randomness 87
Code Button B 87
Save, Test, and Debug Your Program 89
Transfer Your Program to the micro:bit 89
Share Your Program with the World 90
Enhance Your Toy 90
Chapter 7: Mondrian Art Toy 91
Brainstorm 92
Start a New Project 92
Add a Background Color 93
Sidebar: RGBA Color 95
Add a Title Label 96
Add Fill and Clear Buttons 97
Code a Canvas and Paintbrush 99
Code to Draw a Rectangle 101
Code to Fill Rectangles with Color 102
Code a Clear Button to Erase a Painting 103
Save, Test, and Debug Your App 105
Share Your App with the World 105
Enhance Your App 106
Part 3: Moving from Here to There, Again and Again 107
Chapter 8: Emoji Explosion 109
Brainstorm 110
Start a New Project 110
Add a Backdrop 110
Add an Emoji Sprite 111
Code the Stage to Play a Sound 113
Code the Green Flag for the Emoji Sprite 115
Sidebar: Cloning and Inheritance 116
Code the makeEmojis Block 118
Code when I start as a clone for the Emoji Sprite 119
Code the explode Block for the Emoji Clones 121
Save, Test, and Debug Your Program 123
Share Your Program with the World 124
Enhance Your Animated Scene 124
Sidebar: Setting Position 124
Sidebar: Setting Direction 127
Sidebar: Moving 129
Sidebar: Simple Repeat Loops 130
Sidebar: New Blocks (aka Functions) 131
Chapter 9: Smelephant 133
Brainstorm 134
Start a New Project 134
Add a Backdrop 134
Add a Smelephant Sprite 135
Sidebar: Rotation Style in Scratch 137
Code the Green Flag Code of the Smelephant 138
Code the Smelephant’s Up Arrow Key Control 139
Sidebar: Animating Shapes 141
Code Arrow Keys for Moving the Smelephant Down, Left, and Right 144
Add a Flower Sprite 145
Code the Green Flag for the Flower Sprite 147
Code the makeFlowers Block 148
Code when I start as a clone for the Flower Sprite 150
Code the getSmelled Block for the Flower Clones 151
Add a Monkey Sprite 153
Code the Green Flag for the Monkey 154
Code the chase Block 155
Save, Test, and Debug Your Program 158
Share Your Program with the World 158
Enhance Your Animated Scene 158
Sidebar: Key Control 159
Sidebar: Collisions 160
Sidebar: Show and Hide 162
Part 4: Variables, Simple Conditionals, and I/O 163
Chapter 10: Mascot Greeter 165
Brainstorm 166
Start a New Project 166
Sidebar: Inputs and Outputs (I/O) 167
Add a Backdrop 168
Add a Mascot Sprite 168
Add Text-to-Speech Commands 169
Sidebar: Strings and String Operations 170
Code the Mascot Sprite to Greet 171
Save, Test, and Debug Your Program 173
Share Your Program with the World 173
Enhance Your Program 173
Chapter 11: Weird Text Message 174
Brainstorm 175
Start a New Project 175
Name the Input Screen for the App 176
Add a Background Color to the Input Screen 176
Add an Instruction Label 177
Add Category Labels and Text Input Fields 178
Add a Button to Trigger the Action 181
Add and Name an Output Screen 183
Add a Message Image to the Output Screen 183
Add a Message Label to the Output Screen 185
Code the App 186
Save, Test, and Debug Your App 188
Share Your App with the World 189
Enhance Your App 189
Sidebar: Dilbert’s Jargonator 190
Sidebar: ELIZA, the Turing Test, and AI 191
Chapter 12: Vote Machine 192
Brainstorm 193
Start a New Project 193
Rename the Screen 194
Add a Title Label to the App 194
Add Images for the Candidates 195
Add Labels for Each Candidate 197
Code Variables for the First Candidate 198
Code the First Candidate to Register a Vote 199
Sidebar: Working with Number Variables 200
Code Variables for the Remaining Candidates 204
Sidebar: Changing and Incrementing Variable Values 205
Code Remaining Candidates to Register Votes 206
Save, Test, and Debug Your App 207
Share Your App with the World 208
Enhance Your App 208
Chapter 13: Happy New Year! 209
Brainstorm 210
Start a New Project 210
Add a Backdrop 211
Add a Glittery Ball 211
Code the Ball to Drop 213
Create a Countdown Variable 214
Sidebar: Google Language Translation 217
Add Text-to-Speech and Translate Commands 217
Add a Cheer Sound to the Ball Sprite 218
Code the Countdown Clock 219
Sidebar: Decrementing a Variable 221
Save, Test, and Debug Your Program 223
Sidebar: Simple Conditionals and Booleans 223
Share Your Program with the World 224
Enhance Your Toy 224
Chapter 14: Light Theremin 225
Brainstorm 226
Start a New Project 227
Code the First Sound Conditional 228
Code More Sound Conditionals 231
Sidebar: Advanced Conditionals 232
Save, Test, and Debug Your Program 236
Sidebar: IoT and Sensors in Circuits 236
Transfer Your Program to the micro:bit 237
Share Your Program with the World 238
Enhance Your Toy 238
Part 5: Lists, Loops, and Logic 239
Chapter 15: Magic 8-Ball 241
Brainstorm 242
Start a New Project 242
Code on start 243
Sidebar: Simple Lists (Arrays) 245
Code on shake 246
Save, Test, and Debug Your Program 248
Transfer Your Program to the micro:bit 249
Share Your Program with the World 249
Enhance Your Toy 249
Sidebar: eToys 250
Chapter 16: Sock Sort 252
Brainstorm 253
Start a New Project 253
Add a Backdrop 254
Add Red and White Sock Sprites 255
Add Mixed, Red, and White Lists 256
Code the Green Flag (Create List) 258
Code the clearLists Block 263
Code the Sorting Process 264
Save, Test, and Debug Your Program 268
Share Your Program with the World 268
Enhance Your Program 268
Sidebar: Sorting Algorithms 269
Chapter 17: Evil Olive 272
Brainstorm 273
Start a New Project 273
Add a Background Image to the Screen 273
Add an Instruction Label 274
Add a Text Input Field 276
Create and Add Evil Olive to the Screen 277
Add a Message Label to the Screen 278
Code the App 279
Save, Test, and Debug Your App 282
Share Your App with the World 283
Enhance Your App 283
Sidebar: For Loops 284
Sidebar: Searching Algorithms 285
Chapter 18: Sushi Matchup 286
Brainstorm 287
Start a New Project 288
Draw a Toy Interface on the Backdrop 288
Add a Button Sprite 292
Add Reels Sprites 293
Add a Status Sprite 296
Code the Button to Trigger the Spin 299
Create wear Variables 302
Add Sounds 304
Code the Reels to Spin 306
Code the checkMatch Block 309
Code the status Sprite 314
Save, Test, and Debug Your Program 315
Share Your Program with the World 315
Enhance Your Program 316
Sidebar: Broadcasting 316
Sidebar: Logical Operators 317
Part 6: Onwards and Upwards 319
Chapter 19: Creating and Sharing 321
Programming Your Own Ideas 322
Sharing and Showcasing Your Work 325
Chapter 20: Where to Go from Here 336
Upping Your Game 337
Next Steps 340
Index 343