Button counter
Use a variable to count button presses. Beginner · 10 min
Start this tutorial in TinkerPie Studio
Step by step
Make a variable
Open Variables and press Create variable…. Call it
count.Start at zero
Put
set count to 0insideon start.React to button A
From Input, drag
on button A pressedonto the workspace. Inside it putchange count by 1.Show the number
Add
show numberunder it and drop the roundcountblock into its slot.Test in the simulator
Press Run, then click button A on the board picture (or press the A key). The number goes up.
Add a reset
Add
on button B pressedwithset count to 0. Now B starts again from zero.
Questions
What is a variable?
A variable is a named box that stores a value, such as a number. Here, count remembers how many times button A was pressed.
Do I need the TinkerPie board for this tutorial?
No. Press Run and click button A on the board picture, or press the A key on your keyboard. On a real TinkerPie V1, press the A button.
What should I try next?
Try Rainbow and JavaScript to see your blocks as code, or open a ready-made project.