Micro:bit krúžok: Rozdiel medzi revíziami
Zo stránky SensorWiki
Riadok 4: | Riadok 4: | ||
* '''Expansion connector''' | * '''Expansion connector''' | ||
* [https://www.sparkfun.com/products/13989] product page | * [https://www.sparkfun.com/products/13989 SparkFun micro:bit Breakout] product page | ||
* [https://learn.sparkfun.com/tutorials/microbit-breakout-board-hookup-guide Hookup guide] | * [https://learn.sparkfun.com/tutorials/microbit-breakout-board-hookup-guide Hookup guide] | ||
* [https://learn.sparkfun.com/tutorials/sparkfun-inventors-kit-for-microbit-experiment-guide/experiment-11-using-the-compass Experiment guide] | * [https://learn.sparkfun.com/tutorials/sparkfun-inventors-kit-for-microbit-experiment-guide/experiment-11-using-the-compass Experiment guide] | ||
Riadok 16: | Riadok 16: | ||
[[Súbor:microBitEdgeConnector.png|center|300px]] | [[Súbor:microBitEdgeConnector.png|center|300px]] | ||
'''7. marca 2018''' | '''7. marca 2018''' | ||
* | Skupina 12:30: robili sme diaľkové ovládanie robota druhým microbitom. | ||
A+B - rovno, A - doprava, B - doľava inak stop. Fungovalo. | |||
* [https://makecode.microbit.org/_04AbrA8i80yA program pre ovládač] | |||
* [https://makecode.microbit.org/_6zb3tAf8DTjT program pre mmicro:bot] | |||
<source lang="javascript"> | <source lang="javascript"> |
Verzia z 11:10, 8. marec 2018
Návody
Súbor:SparkfunExpansionConnector
- Expansion connector
- SparkFun micro:bit Breakout product page
- Hookup guide
- Experiment guide
- micro:bot
- SparkFun micro:bot kit product page
- SparkFun moto:bit + schematic diagram
- micro:bot Kit Experiment Guide
7. marca 2018
Skupina 12:30: robili sme diaľkové ovládanie robota druhým microbitom. A+B - rovno, A - doprava, B - doľava inak stop. Fungovalo.
radio.setGroup(1)
basic.forever(() => {
if (input.buttonIsPressed(Button.AB)) {
radio.sendString("FORWARD")
basic.showLeds(`
. . # . .
. # # # .
# . # . #
. . # . .
. . # . .
`)
} else if (input.buttonIsPressed(Button.B)) {
radio.sendString("LEFT")
basic.showLeds(`
. . # . .
. # . . .
# # # # #
. # . . .
. . # . .
`)
} else if (input.buttonIsPressed(Button.A)) {
radio.sendString("RIGHT")
basic.showLeds(`
. . # . .
. . . # .
. # # # #
. . . # .
. . # . .
`)
} else {
radio.sendString("OFF")
basic.showLeds(`
. # # # .
# # . # #
# . # . #
# # . # #
. # # # .
`)
}
})
input.onButtonPressed(Button.A, () => {
motobit.setMotorSpeed(Motor.Right, MotorDirection.Forward, 100)
basic.showLeds(`
. . . . .
. . # . .
. . # . .
. . . . .
. . . . .
`)
})
input.onButtonPressed(Button.B, () => {
motobit.enable(MotorPower.On)
basic.showLeds(`
# . . . .
. # . . .
. . # . .
. . . # .
. . . . #
`)
})
function ON() {
motobit.enable(MotorPower.On)
}
function OFF() {
motobit.enable(MotorPower.Off)
}
function 前進() {
motobit.setMotorSpeed(Motor.Right, MotorDirection.Forward, 30)
motobit.setMotorSpeed(Motor.Left, MotorDirection.Forward, 30)
}
radio.onDataPacketReceived( ({ receivedString }) => {
if (receivedString == "ON") {
ON()
} else if (receivedString == "OFF") {
OFF()
} else if (receivedString == "FORWARD") {
前進()
} else if (receivedString == "BACK") {
後進()
} else if (receivedString == "RIGHT") {
右折()
} else if (receivedString == "LEFT") {
左折()
} else {
OFF()
}
})
function 左折() {
motobit.setMotorSpeed(Motor.Right, MotorDirection.Forward, 30)
motobit.setMotorSpeed(Motor.Left, MotorDirection.Reverse, 30)
}
function 右折() {
motobit.setMotorSpeed(Motor.Right, MotorDirection.Reverse, 30)
motobit.setMotorSpeed(Motor.Left, MotorDirection.Forward, 30)
}
function 後進() {
motobit.setMotorSpeed(Motor.Right, MotorDirection.Reverse, 30)
motobit.setMotorSpeed(Motor.Left, MotorDirection.Reverse, 30)
}
radio.setGroup(1)
basic.showLeds(`
. . # . .
. . . . .
# # # # #
. . . . .
. . # . .
`)