Search
About

Damien works with students and teacher from around the world, bringing the effective use of technology to the classroom.  

LEGO MINDSTORMS
Damien is a member of the MCP (Mindstorms Community Program), a small group of experts who collaborate with LEGO to make the MINDSTORM product better.

VEX IQ Robotics
Damien is a member of the VEX IQ Super User group, a small group of experts who collaborate with VEX to make the VEX IQ platform a better product 

 

Books

Teacher Resource Books

Global Map

See where the DomaBot and RileyRover is being used around the world

« QSITE - Quick Journal article | Main | Latest BrickJournal Article »
Tuesday
Sep302014

Using Variables in EV3, where to start?

I'm often asked what 'variables' are and how are they useful?  How would I go about teaching them in class?  Well the question was raised again this week on our Robotics in Education Mailing list so I thought I'd do a very quick blog post on how I approach it.

Count the number of times a button is pressed and display on the screen. (click for large version)

Basically the program is as follows

  • Write a '0' to the 'count' variable (just in case it was something else)
  • Wait for someone to bump the touch sensor (not push)
  • Take the variable -> Add 1 to it -> store the new number back in the variable
  • Display the variable number on the screen
  • Loop back to wait for the next button press

 

Ask the kids why they don't see the '0' when the program starts, but do see the '1' the first time the button is pressed.  Ask them to fix it up so they see a 0.

We then take this and add another button and make a voting machine.  Do you like Chocolate or Vanilla Icecream?  This is then a great lead in for statistics etc :)

 

 

 

EmailEmail Article to Friend

Reader Comments (5)

How do you display the value of the variables?

February 11, 2016 | Unregistered CommenterRhys Kippen

Hy Rhys,
Use the 'Display' blcok and set the input field (top right part of the block) to be 'Wired'. You'll then get an extra input box (bottom left) that you can send the variable wire to.

February 12, 2016 | Registered CommenterDamien Kee

I tried to do this and it didn't work...

May 23, 2016 | Unregistered CommenterAlex Xiang

How do you make a colour as a variable?

May 16, 2017 | Unregistered CommenterJacob

Gracias por compartir sus conocimientos, desde Bolivia estamos muy agradecidos

November 14, 2017 | Unregistered CommenterOSO

PostPost a New Comment

Enter your information below to add a new comment.
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>