Skip to content

Latest commit

 

History

History
386 lines (376 loc) · 14.9 KB

wind-gr-6-lesson.md

File metadata and controls

386 lines (376 loc) · 14.9 KB

How Wind Turbines Capture Kinetic Energy

fwd-edu-breakout=github:climate-action-kits/pxt-fwd-edu/fwd-breakout
=github:climate-action-kits/pxt-fwd-edu

Step 1 @showdialog

Welcome to How Wind Turbines Capture Kinetic Energy Coding Tutorial. built project

Step 2 @showdialog

In this tutorial we will calculate the time for revolutions and then use it to solve the equation to find the (RPM) of the Wind Turbine.

Step 3 @showdialog

Turn on the Climate Action Kit board. breakout board

Step 4 @showhint

Click three dots besides |Download| button, and click on Connect Device. Next, follow the steps to pair your micro:bit. pair gif

Step 5 @showhint

Next, click the |Download| button to download the blank project to start-up the simulators.

Step 6 @showhint

Look below the @boardname@ simulator to see the Climate Action Board and the connected sensors. Try turning the Dial on your project, the virtual simulator will react to it. wind

Step 7

Click ||fwdSensors:Sensors|| drag and drop ||fwdSensors:on dial1 turned difference|| block in workspace.

fwdSensors.dial1.fwdOnDialTurned(fwdSensors.DialDirection.CW, function (difference) {
    })

Step 8

Right click ||fwdSensors:on dial1 turned difference|| block and duplicate. Note: New block will be grey. greyed out example

Step 9

Change the direction arrow of the greyed out ||fwdSensors:on dial1 turned difference|| block. Note: Greyed out block will turn green. dial direction

fwdSensors.dial1.fwdOnDialTurned(fwdSensors.DialDirection.CW, function (difference) {
    })
fwdSensors.dial1.fwdOnDialTurned(fwdSensors.DialDirection.CCW, function (difference) {
    })

Step 10

Click ||fwdSensors:Sensors|| drag and drop ||fwdSensors:on touch down|| block in workspace.

fwdSensors.touch.fwdOnTouch(jacdac.ButtonEvent.Down, function () {
    })
fwdSensors.dial1.fwdOnDialTurned(fwdSensors.DialDirection.CW, function (difference) {
    })
fwdSensors.dial1.fwdOnDialTurned(fwdSensors.DialDirection.CCW, function (difference) {
    })

Step 11

Click ||fwdMotors:Motors|| drag and drop ||fwdMotors:set leftServo to 50 %|| inside ||fwdSensors:on dial1 turned difference|| block. Change ||fwdMotors:leftServo|| to ||fwdMotors:middleServo||.

fwdSensors.touch.fwdOnTouch(jacdac.ButtonEvent.Down, function () {
    })
fwdSensors.dial1.fwdOnDialTurned(fwdSensors.DialDirection.CW, function (difference) {
    fwdMotors.middleServo.fwdSetSpeed(50)
})
fwdSensors.dial1.fwdOnDialTurned(fwdSensors.DialDirection.CCW, function (difference) {
    })

Step 12

Right click ||fwdMotors:set middleServo to 50 %|| block and duplicate. Drag and drop inside the second ||fwdSensors:on dial1 turned difference|| block.

fwdSensors.touch.fwdOnTouch(jacdac.ButtonEvent.Down, function () {
    })
fwdSensors.dial1.fwdOnDialTurned(fwdSensors.DialDirection.CW, function (difference) {
    fwdMotors.middleServo.fwdSetSpeed(50)
})
fwdSensors.dial1.fwdOnDialTurned(fwdSensors.DialDirection.CCW, function (difference) {
    fwdMotors.middleServo.fwdSetSpeed(50)
})

Step 13

Click ||fwdSensors:Sensors||. Drag ||fwdSensors:dial1 absolute position|| oval block close to ||fwdMotors:set middleServo 50 %|| replace ||fwdMotors:50 %|| of ||fwdMotors:set middleServo 50 %|| block.

fwdSensors.touch.fwdOnTouch(jacdac.ButtonEvent.Down, function () {
})
fwdSensors.dial1.fwdOnDialTurned(fwdSensors.DialDirection.CW, function (difference) {
    fwdMotors.middleServo.fwdSetSpeed(fwdSensors.dial1.fwdPosition())
})
fwdSensors.dial1.fwdOnDialTurned(fwdSensors.DialDirection.CCW, function (difference) {
    fwdMotors.middleServo.fwdSetSpeed(50)
})

Step 14

Repeat the last step, click ||fwdSensors:Sensors||. Drag ||fwdSensors:dial1 absolute position|| oval block close to the other ||fwdMotors:set middleServo 50 %|| replace ||fwdMotors:50 %|| of ||fwdMotors:set middleServo 50 %|| block.

fwdSensors.touch.fwdOnTouch(jacdac.ButtonEvent.Down, function () {
})
fwdSensors.dial1.fwdOnDialTurned(fwdSensors.DialDirection.CW, function (difference) {
    fwdMotors.middleServo.fwdSetSpeed(fwdSensors.dial1.fwdPosition())
})
fwdSensors.dial1.fwdOnDialTurned(fwdSensors.DialDirection.CCW, function (difference) {
    fwdMotors.middleServo.fwdSetSpeed(fwdSensors.dial1.fwdPosition())
})

Step 15

Click ||fwdMotors:Motors|| drag and drop ||fwdMotors:set leftServo 50 %|| block inside ||fwdSensors:on touch down|| block. Change ||fwdMotors:leftServo|| to ||fwdMotors:middleServo||.

fwdSensors.touch.fwdOnTouch(jacdac.ButtonEvent.Down, function () {
    fwdMotors.middleServo.fwdSetSpeed(50)
})
fwdSensors.dial1.fwdOnDialTurned(fwdSensors.DialDirection.CW, function (difference) {
    fwdMotors.middleServo.fwdSetSpeed(fwdSensors.dial1.fwdPosition())
})
fwdSensors.dial1.fwdOnDialTurned(fwdSensors.DialDirection.CCW, function (difference) {
    fwdMotors.middleServo.fwdSetSpeed(fwdSensors.dial1.fwdPosition())
})

Step 16

Change speed of ||fwdMotors:set middleServo 50 %|| block inside ||fwdSensors:on touch down|| to ||0||.

fwdSensors.touch.fwdOnTouch(jacdac.ButtonEvent.Down, function () {
    fwdMotors.middleServo.fwdSetSpeed(0)
})
fwdSensors.dial1.fwdOnDialTurned(fwdSensors.DialDirection.CW, function (difference) {
    fwdMotors.middleServo.fwdSetSpeed(fwdSensors.dial1.fwdPosition())
})
fwdSensors.dial1.fwdOnDialTurned(fwdSensors.DialDirection.CCW, function (difference) {
    fwdMotors.middleServo.fwdSetSpeed(fwdSensors.dial1.fwdPosition())
})

Step 17

Click on ||Variables:Variables|| and make ||Variables:2|| ||Variables:Variables||.

  • ||Variables:start_time||
  • ||Variables:stop_time||
fwdSensors.touch.fwdOnTouch(jacdac.ButtonEvent.Down, function () {
    fwdMotors.middleServo.fwdSetSpeed(0)
})
fwdSensors.dial1.fwdOnDialTurned(fwdSensors.DialDirection.CCW, function (difference) {
    fwdMotors.middleServo.fwdSetSpeed(fwdSensors.dial1.fwdPosition())
})
fwdSensors.dial1.fwdOnDialTurned(fwdSensors.DialDirection.CW, function (difference) {
    fwdMotors.middleServo.fwdSetSpeed(fwdSensors.dial1.fwdPosition())
})

Step 18

Click on ||Variables:Variables|| drag and drop ||Variables:set start_time to 0|| inside ||Basic:on start|| block. Repeat this for ||Variables:set stop_time to 0|| block.

let stop_time = 0
let start_time = 0
fwdSensors.touch.fwdOnTouch(jacdac.ButtonEvent.Down, function () {
    fwdMotors.middleServo.fwdSetSpeed(0)
})
fwdSensors.dial1.fwdOnDialTurned(fwdSensors.DialDirection.CCW, function (difference) {
    fwdMotors.middleServo.fwdSetSpeed(fwdSensors.dial1.fwdPosition())
})
fwdSensors.dial1.fwdOnDialTurned(fwdSensors.DialDirection.CW, function (difference) {
    fwdMotors.middleServo.fwdSetSpeed(fwdSensors.dial1.fwdPosition())
})

Step 19

Click ||Input:Input|| drag and drop ||Input:on button A pressed|| block on the workspace.

let stop_time = 0
let start_time = 0
fwdSensors.touch.fwdOnTouch(jacdac.ButtonEvent.Down, function () {
    fwdMotors.middleServo.fwdSetSpeed(0)
})
fwdSensors.dial1.fwdOnDialTurned(fwdSensors.DialDirection.CCW, function (difference) {
    fwdMotors.middleServo.fwdSetSpeed(fwdSensors.dial1.fwdPosition())
})
fwdSensors.dial1.fwdOnDialTurned(fwdSensors.DialDirection.CW, function (difference) {
    fwdMotors.middleServo.fwdSetSpeed(fwdSensors.dial1.fwdPosition())
})
input.onButtonPressed(Button.A, function () {
})

Step 20

Click ||Input:Input|| drag and drop another ||Input:on button A pressed|| block on the workspace. Note: This block will be greyed out. Change the ||Input:button A|| to ||Input:button B||.

let stop_time = 0
let start_time = 0
fwdSensors.touch.fwdOnTouch(jacdac.ButtonEvent.Down, function () {
    fwdMotors.middleServo.fwdSetSpeed(0)
})
fwdSensors.dial1.fwdOnDialTurned(fwdSensors.DialDirection.CCW, function (difference) {
    fwdMotors.middleServo.fwdSetSpeed(fwdSensors.dial1.fwdPosition())
})
fwdSensors.dial1.fwdOnDialTurned(fwdSensors.DialDirection.CW, function (difference) {
    fwdMotors.middleServo.fwdSetSpeed(fwdSensors.dial1.fwdPosition())
})
input.onButtonPressed(Button.A, function () {
})
input.onButtonPressed(Button.B, function () {
})

Step 21

Click ||Variables:Variables|| drag and drop ||Variables:set start_time to 0|| inside ||Input:on button A pressed||.

let stop_time = 0
let start_time = 0
fwdSensors.touch.fwdOnTouch(jacdac.ButtonEvent.Down, function () {
    fwdMotors.middleServo.fwdSetSpeed(0)
})
fwdSensors.dial1.fwdOnDialTurned(fwdSensors.DialDirection.CCW, function (difference) {
    fwdMotors.middleServo.fwdSetSpeed(fwdSensors.dial1.fwdPosition())
})
fwdSensors.dial1.fwdOnDialTurned(fwdSensors.DialDirection.CW, function (difference) {
    fwdMotors.middleServo.fwdSetSpeed(fwdSensors.dial1.fwdPosition())
})
input.onButtonPressed(Button.A, function () {
start_time = 0
})
input.onButtonPressed(Button.B, function () {
})

Step 22

Click ||Variables:Variables|| drag and drop ||Variables:set stop_time to 0|| inside ||Input:on button B pressed||.

let stop_time = 0
let start_time = 0
fwdSensors.touch.fwdOnTouch(jacdac.ButtonEvent.Down, function () {
    fwdMotors.middleServo.fwdSetSpeed(0)
})
fwdSensors.dial1.fwdOnDialTurned(fwdSensors.DialDirection.CCW, function (difference) {
    fwdMotors.middleServo.fwdSetSpeed(fwdSensors.dial1.fwdPosition())
})
fwdSensors.dial1.fwdOnDialTurned(fwdSensors.DialDirection.CW, function (difference) {
    fwdMotors.middleServo.fwdSetSpeed(fwdSensors.dial1.fwdPosition())
})
input.onButtonPressed(Button.A, function () {
start_time = 0
})
input.onButtonPressed(Button.B, function () {
stop_time = 0
})

Step 23

Click ||Basic:Basic|| drag and drop ||Basic:show number|| block under ||Variables:set stop_time to 0|| inside ||Input:on button B pressed|| block.

let stop_time = 0
let start_time = 0
fwdSensors.touch.fwdOnTouch(jacdac.ButtonEvent.Down, function () {
    fwdMotors.middleServo.fwdSetSpeed(0)
})
fwdSensors.dial1.fwdOnDialTurned(fwdSensors.DialDirection.CCW, function (difference) {
    fwdMotors.middleServo.fwdSetSpeed(fwdSensors.dial1.fwdPosition())
})
fwdSensors.dial1.fwdOnDialTurned(fwdSensors.DialDirection.CW, function (difference) {
    fwdMotors.middleServo.fwdSetSpeed(fwdSensors.dial1.fwdPosition())
})
input.onButtonPressed(Button.A, function () {
start_time = 0
})
input.onButtonPressed(Button.B, function () {
stop_time = 0
basic.showNumber(0)
})

Step 24

Click ||Math:Math|| drag and drop ||Math:Division operator|| block to replace the ||Basic:0|| of ||Basic:show number|| block. For ||Math:Division|| change the right ||Math:0|| to ||Math:1000||.

let stop_time = 0
let start_time = 0
fwdSensors.touch.fwdOnTouch(jacdac.ButtonEvent.Down, function () {
    fwdMotors.middleServo.fwdSetSpeed(0)
})
fwdSensors.dial1.fwdOnDialTurned(fwdSensors.DialDirection.CCW, function (difference) {
    fwdMotors.middleServo.fwdSetSpeed(fwdSensors.dial1.fwdPosition())
})
fwdSensors.dial1.fwdOnDialTurned(fwdSensors.DialDirection.CW, function (difference) {
    fwdMotors.middleServo.fwdSetSpeed(fwdSensors.dial1.fwdPosition())
})
input.onButtonPressed(Button.A, function () {
start_time = 0
})
input.onButtonPressed(Button.B, function () {
stop_time = 0
basic.showNumber(0/1000)
})

Step 25

Click ||Math:Math|| drag and drop ||Math:Subtraction operator|| block to replace the left ||Math:0|| of ||Math:0 / 1000|| block.

let stop_time = 0
let start_time = 0
fwdSensors.touch.fwdOnTouch(jacdac.ButtonEvent.Down, function () {
    fwdMotors.middleServo.fwdSetSpeed(0)
})
fwdSensors.dial1.fwdOnDialTurned(fwdSensors.DialDirection.CCW, function (difference) {
    fwdMotors.middleServo.fwdSetSpeed(fwdSensors.dial1.fwdPosition())
})
fwdSensors.dial1.fwdOnDialTurned(fwdSensors.DialDirection.CW, function (difference) {
    fwdMotors.middleServo.fwdSetSpeed(fwdSensors.dial1.fwdPosition())
})
input.onButtonPressed(Button.A, function () {
start_time = 0
})
input.onButtonPressed(Button.B, function () {
stop_time = 0
basic.showNumber((0-0)/1000)
})

Step 26

Click ||Variables:Variables|| drag and drop ||Variables:stop_time|| to replace left ||Math:0||. Drag and drop ||Variables:start_time|| to replace right ||Math:0||.

let stop_time = 0
let start_time = 0
let revolutions = 0
let RPM = 0
fwdSensors.touch.fwdOnTouch(jacdac.ButtonEvent.Down, function () {
    fwdMotors.middleServo.fwdSetSpeed(0)
})
fwdSensors.dial1.fwdOnDialTurned(fwdSensors.DialDirection.CCW, function (difference) {
    fwdMotors.middleServo.fwdSetSpeed(fwdSensors.dial1.fwdPosition())
})
fwdSensors.dial1.fwdOnDialTurned(fwdSensors.DialDirection.CW, function (difference) {
    fwdMotors.middleServo.fwdSetSpeed(fwdSensors.dial1.fwdPosition())
})
input.onButtonPressed(Button.A, function () {
start_time = 0
})
input.onButtonPressed(Button.B, function () {
stop_time = 0
basic.showNumber((stop_time - start_time)/1000)
})

Step 27

Click ||Input:Input|| and then ||Input:...more|| drag and drop ||Input:running time|| block to replace ||0|| in ||Variables:start_time|| and ||Variables:stop_time|| nested in ||Input:on button A pressed|| and ||Input:on button B pressed|| respectively.

let stop_time = 0
let start_time = 0
fwdSensors.touch.fwdOnTouch(jacdac.ButtonEvent.Down, function () {
    fwdMotors.middleServo.fwdSetSpeed(0)
})
fwdSensors.dial1.fwdOnDialTurned(fwdSensors.DialDirection.CCW, function (difference) {
    fwdMotors.middleServo.fwdSetSpeed(fwdSensors.dial1.fwdPosition())
})
fwdSensors.dial1.fwdOnDialTurned(fwdSensors.DialDirection.CW, function (difference) {
    fwdMotors.middleServo.fwdSetSpeed(fwdSensors.dial1.fwdPosition())
})
input.onButtonPressed(Button.A, function () {
start_time = input.runningTime()
})
input.onButtonPressed(Button.B, function () {
stop_time = input.runningTime()
basic.showNumber((stop_time - start_time)/1000)
})

Step 28 @showhint

|Download| and test your code. Click the bulb icon to see how the simulator shows the components working. dial-servo

Step 29 @showdialog

Congratulations on completing your How Wind Turbines Capture Kinetic Energy Project!

Step 30 @showdialog

After your project is complete, go back to the lesson for more challenges and extensions.