3 activies from curriculum (#194)

* 3 activies from curriculum

* fixing style
This commit is contained in:
Peli de Halleux 2018-01-05 18:24:23 -08:00 committed by GitHub
parent 9f9ce29476
commit ea46f1cbc7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 85 additions and 4 deletions

28
docs/coding.md Normal file
View File

@ -0,0 +1,28 @@
# Coding Activites
12 computer science activities, with cross-curricular opportunities in design and technology, science, and math.
* [Download Curriculum Materials](https://education.lego.com/en-us/downloads/mindstorms-ev3)
## Activites
```codecard
[
{
"name": "Three Point Turn",
"description": "Activity 1",
"url":"/coding/three-point-turn-1",
"cardType": "example"
}, {
"name": "Three Point Turn",
"description": "Activity 1",
"url":"/coding/three-point-turn-2",
"cardType": "example"
}, {
"name": "Three Point Turn",
"description": "Activity 1",
"url":"/coding/three-point-turn-3",
"cardType": "example"
}
]
```

View File

@ -0,0 +1,12 @@
# Three Point Turn Activity 1
```blocks
brick.buttonEnter.onEvent(ButtonEvent.Click, function () {
motors.largeBC.tank(75, 30)
loops.pause(1500)
motors.largeBC.tank(-30, -75)
loops.pause(1000)
motors.largeBC.tank(50, 50)
loops.pause(3000)
})
```

View File

@ -0,0 +1,14 @@
# Three Point Turn Activity 2
```blocks
brick.buttonEnter.onEvent(ButtonEvent.Click, function () {
motors.largeBC.tank(75, 30)
loops.pause(1500)
motors.largeBC.tank(-30, -75)
sensors.ultrasonic4.pauseUntil(UltrasonicSensorEvent.ObjectNear);
motors.largeBC.tank(0, 0)
loops.pause(1000)
motors.largeBC.tank(50, 50)
loops.pause(3000)
})
```

View File

@ -0,0 +1,15 @@
# Three Point Turn Activity 3
```blocks
brick.buttonEnter.onEvent(ButtonEvent.Click, function () {
motors.largeBC.tank(75, 30)
loops.pause(1500)
motors.largeBC.tank(-30, -75)
sensors.ultrasonic4.pauseUntil(UltrasonicSensorEvent.ObjectNear);
motors.largeBC.tank(0, 0)
music.playSoundEffect(sounds.animalsDogBark1)
loops.pause(1000)
motors.largeBC.tank(50, 50)
loops.pause(3000)
})
```

View File

@ -15,6 +15,7 @@
"MoveUnit.Degrees|block": "degrees",
"MoveUnit.MilliSeconds|block": "milliseconds",
"MoveUnit.Rotations|block": "rotations",
"MoveUnit.Seconds|block": "seconds",
"Output.AB|block": "A+B",
"Output.AD|block": "A+D",
"Output.ALL|block": "All",

View File

@ -30,6 +30,8 @@ enum MoveUnit {
Rotations,
//% block="degrees"
Degrees,
//% block="seconds"
Seconds,
//% block="milliseconds"
MilliSeconds
}
@ -246,6 +248,10 @@ namespace motors {
stepsOrTime = value >> 0;
useSteps = true;
break;
case MoveUnit.Seconds:
stepsOrTime = (value * 1000) >> 0;
useSteps = false;
break;
default:
stepsOrTime = value;
useSteps = false;
@ -265,7 +271,7 @@ namespace motors {
readPWM(buf)
const flags = buf.getNumber(NumberFormat.UInt8LE, 2);
// TODO: FIX with ~ support
for(let i = 0; i < DAL.NUM_OUTPUTS; ++i) {
for (let i = 0; i < DAL.NUM_OUTPUTS; ++i) {
const flag = 1 << i;
if ((this._port & flag) && (flags & flag))
return false;
@ -505,7 +511,7 @@ namespace motors {
this.steerFor(turnRatio, speed, value, unit);
}
/**
* Turns the motor and the follower motor by a number of rotations
* @param turnRatio the ratio of power sent to the follower motor, from ``-200`` to ``200``, eg: 0
@ -554,6 +560,10 @@ namespace motors {
stepsOrTime = value >> 0;
useSteps = true;
break;
case MoveUnit.Seconds:
stepsOrTime = (value * 1000) >> 0;
useSteps = false;
break;
default:
stepsOrTime = value >> 0;
useSteps = false;
@ -567,7 +577,7 @@ namespace motors {
stepsOrTime: stepsOrTime,
useBrake: this._brake
});
}
}
/**
* Returns the name(s) of the motor

View File

@ -8,6 +8,7 @@
]
},
"galleries": {
"Maker Activities": "maker"
"Maker Activities": "maker",
"Coding Activites": "coding"
}
}