Variable Op


Published on

Published in: Technology, Education
  • Be the first to comment

  • Be the first to like this

Variable Op

  1. 1. Value Control with Variables Joe Long Robofest Student Assistant Lawrence Tech Computer Science Major [email_address] April 12, 2007
  2. 2. Create the variable <ul><li>Navigate to the ‘Edit’ menu (next to ‘file’) </li></ul><ul><li>Click on ‘Define Variables’ </li></ul><ul><li>Click ‘create’ and enter </li></ul><ul><li>the variable information </li></ul><ul><li>and type. </li></ul><ul><li>Click ‘Close’ </li></ul>
  3. 3. Getting the light value <ul><li>Open the ‘complete’ block menu ( ) </li></ul><ul><li>Find a Light Sensor block and drag it onto the field. </li></ul>
  4. 4. Saving the value to a variable <ul><li>Find a Variable block and drag it onto the field. </li></ul><ul><li>In the block’s options panel, change it’s Action to ‘Write’ and select your created variable from the List. </li></ul>
  5. 5. Make the Data Wires (light value saved to a variable) <ul><li>Click on the ‘tab’ sticking out of the light block ( ), then click on the back ‘tab’ sticking out of the ‘write’ mode variable block </li></ul><ul><li>The wire should look </li></ul><ul><li>like this: </li></ul>
  6. 6. Read the variable <ul><li>Drag another variable block onto the field. </li></ul><ul><li>In the options panel, select your variable from the list and set the mode to ‘read’. </li></ul><ul><li>The block should look like this </li></ul><ul><li>When you are done: </li></ul>
  7. 7. Add 2 to the variable <ul><li>Find the ‘Math’ block and drag it onto the field. </li></ul><ul><li>Draw a data wire from the second variable block to the ‘A’ tab on the math block: </li></ul>
  8. 8. Using the math block <ul><li>Open the math block’s options panel. </li></ul><ul><li>Set the Operation to ‘Addition’ </li></ul><ul><li>You can see that the space for ‘A’ is grayed out, as it is already used. </li></ul><ul><li>In the ‘B’ space, type in ‘2’ </li></ul>
  9. 9. Convert the answer (number) to text for displaying <ul><li>Find the Number to Text block </li></ul><ul><li>Draw a data wire from the ‘#’ tab of the math block to the ‘#’ tab of the conversion block. </li></ul>
  10. 10. Displaying the value <ul><li>Find the Display block and put it on the field: </li></ul><ul><li>In the display block’s options panel, set the Action to ‘Text’ (the location can also be experimented with) </li></ul><ul><li>The block should now look like this: </li></ul>
  11. 11. Displaying the value <ul><li>Open the display block’s drop down menu (by clicking on the line at the bottom edge of the block) </li></ul><ul><li>Connect a data cable from the </li></ul><ul><li>output of the converter to the </li></ul><ul><li>‘ T’ tab of the display block. </li></ul>
  12. 12. Display the data for 5 seconds <ul><li>Find a Wait block and drag it onto the field: </li></ul><ul><li>In the options panel, set the Control to ‘Time’ and input 5. </li></ul>
  13. 13. Complete <ul><li>Steps: </li></ul><ul><ul><li>Read the light value </li></ul></ul><ul><ul><li>Save it to a variable </li></ul></ul><ul><ul><li>Do…. Whatever comes in-between… </li></ul></ul><ul><ul><li>Read the variable </li></ul></ul><ul><ul><li>Do any required math </li></ul></ul><ul><ul><li>Convert the number to text </li></ul></ul><ul><ul><li>Display the text </li></ul></ul><ul><ul><li>Wait some time before continuing </li></ul></ul>