www.e3robotics.org

www.e3robotics.org

Storing Values as Variables Variable = a place to store a value Sensor values can be stored as variable. Values stored as number variables can be mathematically modified. Text values can have additional text added. The most common use is to compare variables against other values to see if the value meets a certain threshold.

Common uses for Variables: Storing Sensor Values Counting

Storing and Displaying Sensor Values Program a robot to go into a tunnel and take a light sensor reading after 1 rotation; come back out of the tunnel and displays the value.

Start with a program that will drive the robot into the tunnel and then back out of the tunnel. 1 Place two Move Blocks on the sequence beam. One going into the tunnel and another backing out of the tunnel.

1 Programming the sensor readings inside the tunnel Place a light sensor block inside the code following the forward movement. Uncheck Generate light so that the

sensor does not detect its own reflected light inside the tunnel. Detecting the Light Sensors own Reflected Light If the Generate Light checkbox is checked, the light sensor will turn on its own small light source and detect the color that is reflected back to it.

With the Generate light function on, the light sensor can detect the amount of light that is reflected back from a variety of shades of colors. With the Generate light function off the light sensor can detect the amount of ambient light that is surrounding the light sensor. Adding a Variable Block

From the Data Palette place a Variable Block after the Light Sensor Block. Assigning Variable types Light Sensors values are numbers. Configure the Variable Block to use the Number Variable called Number 1. The value must be stored so the Light Sensor must write the value under actions.

Wire the Intensity Output Plug on the Light Sensor Block to the Input Plug on the Variable Block. The Variable Block now holds the value that will need to be displayed after the robot exits the tunnel. Displaying Stored Data

After the Variable Read Block, add a Number to Text Block followed by a Display Block. Wire the Blocks as shown. Configure the Display Block to display the

converted Text. Add a Wait Block at the end of the program to allow time to read the displayed value. Set the wait time to 10 Seconds. 10

Download and run the program. Check the NXT screen for the Light Sensor Display Value. 33 Part Two: Storing and Displaying

More Than One Sensor Values Program the robot to go into a tunnel, take a light sensor reading after 1 rotations and then again after 3 more rotations; come back out of the tunnel and display both values.

Add a 2 rotation Movement Block after the first variable 2 Add another Sensor Block to read the new sensor value and a Variable Block to store the second value.

2 There is only one Number Variable called Number 1, that variable is holding the first sensor value. Create a new

Number Variable. Go to Edit and Define Variables. Create a variable named Number 2. Make the Datatype a Number Configure Variable Block 2 to write to the variable

named Number 2. Wire the output Plug on the Light Sensor Block to the input plug on the Variable Block. Create a second variable display just like the first one. Place the Variable Block before the Wait Block. Format the Variable Block to

Read the Variable named Number 2. Create a second Number to Text just like the first one. Place the Number to Text after the Number 2 Variable Block. Place a Display Block after the Number to Text Block. Wire the blocks together.

Format the Display Block to Text. Display Block Settings The two Display Blocks are set to display the values in exactly the same place on the NXT screen. Change the First

Display Block Display setting by dragging the Mindstorms NXT text to the top of the text box. Change the second Display Block by removing the check from Clear so that both numbers are displayed for 5 seconds.

Currently the robot goes forward 1 rotation then forward 2 more rotations equaling 3 rotations. Change the Reverse Motor Block from 1 rotation to 3 rotations so that the robot completely exits the tunnel before displaying the Sensor Values. 3

Download and Run the Program. The robot should display two light sensor values on the NXT screen.

Recently Viewed Presentations

  • Sci. 4-1 Work and Power Pages 88-91 A.

    Sci. 4-1 Work and Power Pages 88-91 A.

    Work Formula Work equals Force times distance W = F x d SI Units Force = (N) newtons Work = (J) joules distance = (m) meters G. Power- is the rate at which work is done Power Formula Power =...
  • Redesigned Nurse Residency Program & Nurse ... - hsc.ghs.org

    Redesigned Nurse Residency Program & Nurse ... - hsc.ghs.org

    Learning module for assessor ( inter rater reliability) Nurse Readiness for Practice Tool . Nurse Manager completes at one year . Casey Fink Graduate Nurse Experience Survey© Self assessment by new graduate at start of program, 6 months and one...
  • School Motivation and Learning Strategies Inventory (Smalsi)

    School Motivation and Learning Strategies Inventory (Smalsi)

    WHAT IS THE SMALSI. Stroud & Reynolds. 2011 Child and Teen Versions. 2013 College Age Version. Self-report inventory that measures 10 constructs associated with academic motivation and learning strategies
  • Anne Hathaway by Carol Anne Duffy Background and

    Anne Hathaway by Carol Anne Duffy Background and

    Anne Hathaway . is a sonnet spoken in the voice of Anne Hathaway. Because Duffy imagines the speaker as one distinct character, we can call this poem a dramatic monologue. Anne Hathaway . is written in the form of a...
  • Coppin State University

    Coppin State University

    Northfield Mental Healthcare Center. Northfield, Ohio. Senior Thesis 2013. Ji Won Park. Mechanical Option. Advisor: Dr. Stephen Treado
  • Nj Cacfp - Civil Rights Power Point Presentation

    Nj Cacfp - Civil Rights Power Point Presentation

    6 Protected Classes. Race. Color. National Origin . Sex. Age. Disability. Any person or group of people who have characteristics for which discrimination is prohibited based on a law, regulation, or executive order. What are some examples of people or...
  • Presentación de PowerPoint

    Presentación de PowerPoint

    Several clinical trials including the Cholesterol and Recurrent Events (CARE) and Long-term Intervention with Pravastatin in Ischemic Disease (LIPID), have sub-analysed their results for the 'elderly' cohort, but the Prospective Study of Pravastatin in the Elderly at Risk (PROSPER) trial...
  • Implementing Will-Cost and Should Cost Management

    Implementing Will-Cost and Should Cost Management

    Will-Cost Estimate Definition. The budget baseline will be based on a non-advocate will-cost estimate. Aims to provide sufficient resources to execute the program under normal conditions, encountering average levels of technical, schedule, and programmatic risk (usually no less than 50%...