Get Moving to Get Data
Investigate gathering, displaying, and using data
Questions to investigate
• How can you gather and display data?
• Ensure SPIKE Prime hubs are charged, especially if connecting through Bluetooth.
(Group Discussion, 5 minutes)
Engage students in a conversation about transportation and ways that people get around.
Prompts students to share the different ways they get from one place to another. Have them think about what types of transportation they take regularly. Discuss the situations that require the use of different types of transportation.
Provide different examples of places to discuss what transportation types might be used in each place. Be sure to include walking, biking, different types of vehicles, boats, planes, etc.
Ask students to consider when they want to get to these places what is important information or data to have. Discuss ideas like know the distance, how long it will take, and how fast they need to move.
(Small Groups, 20 minutes)
Students will investigate ways to take in data from sensors and manage their data.
Direct students to the BUILD section in the SPIKE App. Here students can access the building instructions for Smart Kettlebell model. Ask students to build the model. The building instructions are also available at https://education.lego.com/en-us/support/spike-prime/building-instructions.
Direct students to open a new project in the Python programming canvas. Ask students to erase any code that is already in the programming area. Students should connect their hub.
Prompt students to think about how to use their sensor to take in information. Students should look at the upper left area of programming canvas will show sensor data. Ask students to move their model around and press the force sensor to see the live data stream. Discuss how moving the model provides different data. Have students indicate ways that they could program the distance sensor to provide data.
Ask students to review the three sample programs. Discuss which will be the best to gather and manage data in the console. Allow students to investigate the programs as needed.
Sample Program 1:
from spike import PrimeHub, DistanceSensor hub = PrimeHub() \# set the variable for distance distance = DistanceSensor('F') \# set the condition to measure the distance repeatedly dist_cm=distance.get_distance_cm() print('cm:', dist_cm)
Sample Program 2:
from spike import PrimeHub, DistanceSensor hub = PrimeHub() \# set the variable for distance distance = DistanceSensor('F') \# set the condition to measure the distance repeatedly while True: dist_cm=distance.get_distance_cm() print('cm:', dist_cm)
Sample Program 3:
from spike import PrimeHub, DistanceSensor, ForceSensor from spike.control import wait_until hub = PrimeHub() \# set the variable for distance and measuring using the force sensor distance = DistanceSensor('F') measure = ForceSensor('B') \# set the condition to measure the distance repeatedly while True: measure.wait_until_pressed() dist_cm=distance.get_distance_cm() print('cm:', dist_cm)
Allow students time to investigate the three programs.
(Whole Group, 5 minutes)
Discuss with students how each program worked. Ask students questions like:
• What did the data output in the console look like for each program?
• Which program would provide the best way to gather different data points?
• What are some ways that you could organize your data outside the console?
Prompt students to display their data in a table.
Remind students that there are different data types: integer, float, and string. Consider referencing the Knowledge Base under the distance sensor to help students decide what type of data is being used here. Discuss what type of data has been provided from their sensor.
(Small Groups, 10 minutes)
Challenge students to create a new program that will provide data using the force sensor.
Ask students to look at the ways that they can get data from the force sensor. Discuss ideas for getting the number of Newtons from pressing the force sensor and displaying the data so students can easily gather and organize the information into a table. Consider ideas for displaying in the console or on the hub.
Allow students time to explore and develop their program. Encourage students to share their ideas and data with other groups.
(Group Exercise, 5 minutes)
Discuss the program with students.
Ask students questions like:
• What is the difference between the three sample programs you investigated? What is the same?
• What happened when you were adding the force sensor?
• What are some ways you can display data to reference or capture to create a table?
Have students answer the following in their journals:
• What did you learn today about gathering data using your robot?
• What characteristics of a good teammate did I display today?
• Ask students to rate themselves on a scale of 1-3, on their time management today.
• Ask student to rate themselves on a scale of 1-3, on their materials (parts) management today.
Supporto per l'insegnante
• Investigate ways to take in data from sensors
• Create a new program that will provide data using the force sensor
• SPIKE Prime sets ready for student use
• Devices with the SPIKE App installed
• Student journals
2-CS-02 Design projects that combine hardware and software components to collect and exchange data.
2-AP-10 Use flowcharts and/or pseudocode to address complex problems as algorithms
2-AP-13 Decompose problems and subproblems into parts to facilitate the design, implementation, and review of programs.
2-AP-16 Incorporate existing code, media, and libraries into original programs, and give attribution.
2-AP-17 Systematically test and refine programs using a range of test cases.
2-AP-19 Document programs in order to make them easier to follow, test, and debug.