gives us three chances to guess what the number is. If we are right, it congratulates us, but if we are wrong, it tells us on the NXT Display whether our guess is too high or too low. Plan a course of action for programming this “game” using the six basic computer operations. You may create your plan either in words or by using a flowchart representation. Note: you do not actually need to program this. Solution: Answers may vary somewhat, but as long as the plan is logical, complete, and breaks down to the six basic actions (input, output, compute, decide, repeat, remember), it deserves full credit. Generate a random number between 1 and 10. (COMPUTE) Set number of guesses to 3 (COMPUTE) REPEAT the following If number of guesses is 0, DECIDE to STOP REPEAT If number of guesses is not 0, DECIDE to Read the guessed value from the numerical input box (INPUT) Compare the value of random to guessed. If random is bigger, DECIDE to Display “Too low!” in string output (OUTPUT) If random is smaller, DECIDE to Display “Too high!” in string output (OUTPUT) If random equals guessed, DECIDE to Display “You got it!” in string output (OUTPUT) Decrease number of guesses by 1 (COMPUTE) Note: you may have chosen to end the game if you guessed the number correctly before three guesses also. This is okay, as long as the arrows are all going to the right places for that plan. Since the homework question didn’t specify, either plan is correct. You may also have chosen to create this as a flowchart, if that is easier for you. As always, the shape of the box communicates whether something is an input/output, computation, or decision, and loops are represented with appropriate arrows. Your flowchart should look something like the one on the next page.
7 4. Basic Calculator using the LabVIEW Front Panel IMPORTANT NOTE : In this week’s and next week’s homework sets, you will be required to do some programming in LabVIEW. LabVIEW is available on the computers in the Learning Center, in Fitzpatrick Hall, and in 303 Cushing Hall. If you installed LabVIEW on your personal computer, but cannot find the NXT menu, you will need to reinstall LabVIEW with the basic install plus the LEGO NXT component checked during installation. When we open a program in LabVIEW, two windows open: the white Block Diagram window and the gray Front Panel window. The Front Panel can be used to represent the inputs and outputs going into a program. Instead of using sensors, motors, and sounds, the Front Panel allows for numerical and text-based inputs and outputs. Instead of a Functions Palette, the Front Panel has a Controls Palette. It can be opened similarly to the way you opened the Functions Palette in Learning Center. Select the NXT Robotics options and you should see something like the screenshot below at left. If you are running LabVIEW without NXT,
You've reached the end of your free preview.
Want to read all 10 pages?
- Fall '14