Presentation is loading. Please wait.

Presentation is loading. Please wait.

Branching and Decisions

Similar presentations


Presentation on theme: "Branching and Decisions"— Presentation transcript:

1 Branching and Decisions
Computer Programming Modeling a Passive Solar Home

2 What We Have Done We have created a sequential program the performs several calculations We added a loop to repeat these calculations in order to estimate the indoor temperature of a house over a longer period of time Have the students bring up Scratch on their computers to follow along.

3 Branching and Decisions
Sometimes we want to do something only if something else is true Example: A thermostat turns on the heat in your home only if the temperature is below the desired temperature. Otherwise the heater is left off This could be written as If the indoor temperature is below the desired temperature then Turn on the heater Else Turn off the heater Have the students bring up Scratch on their computers to follow along.

4 Branching in Scratch You can use the “If” Control blocks to branch in scratch The block on the left runs the blocks inside of it if a condition is true The block on the right runs one set of blocks if the condition is true and a different set of blocks if it is not true (“else”).

5 Activity: Moving a Sprite
Open a new Scratch file and go to the script tab for the sprite Make the script shown to the right that has the Sprite move during the first 5 times through the loop and spin otherwise Run the script by clicking on the flag You will need to create the variable “mycounter” and add blocks to initialize it to zero and to increment it by 1 each time through the loop.

6 Activity: Moving a Sprite
Does the behavior match your expectation? Modify the condition (change the five to another number, use an “equal” operator instead of “>”, etc.) and observe the effects.

7 Using myCounter In the example, a new variable was made called “myCounter”. It could have had any name. Its only purpose was to count how many times the loop was performed. It increases by 1 each time through the loop. You do not need a variable for counting if your decision was based off of something else, such as indoor temperature.

8 Activity: Heat Loss in a Home
You will modify your indoor temperature model to allow passive solar heating to be added in the second hour. This is a simplified model where the sun rises instantly after 6 hours of letting a house cool down

9 Passive Solar Heating Passive solar heating can reduce energy use in many areas of the country where there are sunny days during cold winter months Solar heating takes advantage of available sunshine to heat a home Passive means the heating occurs without active mechanical systems or daily intervention of the people living in the home Solar can also produce hot water and electricity Public image from energy.gov: .

10 Passive Solar Homes Passive solar homes typically include
Ample window area with southern exposure High efficiency windows that better retain inside heat Construction techniques and materials that reduce heat loss and store warmth Features that reduce solar heat input during summer months Original image of a passive solar home in NC. The three large windows face south while the other window faces east. A four inch thick concrete floor moderates temperature swings.

11 Accounting for Passive Solar Gain
In our prior model we used the following equations to calculate the temperature change:

12 Accounting for Passive Solar Gain
Passive solar heat gain can be thought of as a “negative heat loss”. That is to say, if your loss is negative, you’ve gained heat. Thinking about passive solar heat gain in this way allows us to use the same equation and model as before. We subtract solar gain from the heat loss when solar gain is available. In Scratch, the command would be Change Heat Loss by (-1 * Solar Gain)


Download ppt "Branching and Decisions"

Similar presentations


Ads by Google