edit

# States of Matter

## States of Matter¶

Make a states of matter experiment that responds to your micro:bit wand or micro:bit’s movement!

https://youtu.be/Hdsy93yaQC0

### Duration¶

The activity is approx 30-45 min based on familiarity with the coding concepts

### Materials¶

• Cardboard
• Aluminum Foil
• Permanent Markers (Red and Black)
• 1 micro:bit, battery holder and 2 AAA batteries
• 4 Crocodile clips
• Activities

Turn a piece of cardboard into a detector of temperature and atmospheric temperature!

https://youtu.be/Hdsy93yaQC0

• Fold the foil squares and place them around the cardboard.
• Connect each piece of foil to the appropriate pin on the micro:bit.

That’s it!

### Code¶

Have you ever tried to represent the states of matter? Let’s try to visually represent various states of matter based on atmospheric temperatures!

#### Step 1: Variables.¶

In order for States of Matter to follow the rules for determining the atmospheric temperature, we need to add variables that will store data. Then we will assign (set) the value of the variables. We want to name the two (2) variables as follows: “atmos_temperature” and “temperature”. Set the value of the variables to 100. Modify your code so that it looks like this.

#### Step 2: Detect a solid.¶

We want to detect when the solid state occurs. On Pin 2 Pressed, you want to represent an atmospheric temperature of 0 and scroll the message “SOLID”. We want to set atmos_temperature to 0 and show the string: “SOLID”. Modify your code to look like this:

#### Step 3: Detect a liquid.¶

We want to detect when the liquid state happens. On Pin 1 Pressed, you want to represent an atmospheric temperature of 80 and scroll the message “LIQUID”. We want to set atmos_temperature to 80 and show the string: “LIQUID”. Modify your code to look like this:

#### Step 4: Detect a gas.¶

We want to detect when matter will be a gas. On Pin 0 Pressed, you want to represent an atmospheric temperature of 80 and scroll the message “GAS”. We want to set atmos_temperature to 250 and show the string: “GAS”. Modify your code to look like this:

#### Step 5: Increase temperature.¶

We want to display a change of temperature on shake. When you shake the states of matter experiment, there will be a show icon to represent an increase in temperature. Modify your code to add the shake event: