diff --git a/CuteBotController.md b/CuteBotController.md
index 4d05b3a..f82def5 100644
--- a/CuteBotController.md
+++ b/CuteBotController.md
@@ -2,27 +2,29 @@
# STEM - CuteBot Controller
## Let's build a robot controller @showdialog
Let's build a micro:bit project that will drive a CuteBot by sending messages over radio signal.
-To help you out, we've created some variables that you will need later: ``||variables: Forwards, Reverse, Left, Right, Stop||``.
+To help you out, we've created some variables that you will need later: ``||variables: Forwards, Backwards, Left, Right, Stop||``.
```validation.global
# BlocksExistValidator
```
```template
let Forwards = "FORWARDS"
-let Reverse = "REVERSE"
+let Backwards = "BACKWARDS"
let Left = "LEFT"
let Right = "RIGHT"
let Stop = "STOP"
let Direction = "STOP"
+let Rainbow = "RAINBOW"
```
```blocks
let Forwards = "FORWARDS"
-let Reverse = "REVERSE"
+let Backwards = "BACKWARDS"
let Left = "LEFT"
let Right = "RIGHT"
let Stop = "STOP"
let Direction = "STOP"
+let Rainbow = "RAINBOW"
```
-## Show your micro:bit name
+## Show your micro:bit name
Let's start by dragging a ``||basic:Basic:show string||`` block into the top of ``||basic:on start||``.
Drag ``||control:Control:device name||`` into to ``||basic:show string||``; this will show your micro:bit's name.
@@ -30,11 +32,12 @@ Drag ``||control:Control:device name||`` into to ``||basic:show string||``; this
// @highlight
basic.showString(control.deviceName())
let Forwards = "FORWARDS"
-let Reverse = "REVERSE"
+let Backwards = "BACKWARDS"
let Left = "LEFT"
let Right = "RIGHT"
let Stop = "STOP"
let Direction = "STOP"
+let Rainbow = "RAINBOW"
```
## Set your radio group
Drag a ``||radio:Radio:set group||`` block into ``||basic:on start||``; enter your radio group number. Use a ``||basic:Basic:show string||`` block to show your radio group number.
@@ -45,11 +48,12 @@ radio.setGroup(1)
//@highlight
basic.showString("1")
let Forwards = "FORWARDS"
-let Reverse = "REVERSE"
+let Backwards = "BACKWARDS"
let Left = "LEFT"
let Right = "RIGHT"
let Stop = "STOP"
let Direction = "STOP"
+let Rainbow = "RAINBOW"
```
## Add a Loop block to your canvas
To control your CuteBot, drag a ``||loops:Loops:every 500ms||`` block onto your canvas, change the 500ms to 100ms.
@@ -109,11 +113,11 @@ let Direction = Stop
}
})
```
-## Check for tilt backwards (reverse)
+## Check for tilt backwards (Backwards)
Drag an ``||logic:if true then||`` block into the bottom of the ``||loops:every 100ms||`` block.
Drag a ``||logic:Logic:0>0||`` comparision block into the ``||logic:if||`` block.
Drag ``||input:Input:rotation||`` into left side of the number comparision and set to ">" 60 (greater than 60).
-Drag ``||variables:Variables: set xyz = 0||`` inside the ``||logic:if||`` block and set ``||variables:Direction||`` to ``||variables:Reverse||``.
+Drag ``||variables:Variables: set xyz = 0||`` inside the ``||logic:if||`` block and set ``||variables:Direction||`` to ``||variables:Backwards||``.
```blocks
loops.everyInterval(100, function () {
let Direction = Stop
@@ -128,102 +132,45 @@ let Direction = Stop
}
// @highlight
if (input.rotation(Rotation.Pitch) > 60) {
- Direction = Reverse
+ Direction = Backwards
}
})
```
-## Step 6 - Add radio send "Backwards"
-Drag ``||radio:Radio:send string||`` into the if-block and send the value "Backwards"
+## Finally, let's send our command to the Cutebot
+Drag ``||radio:Radio:send string||`` into the bottom of the the ``||loops:loops.everyInterval(100)||`` block.
+Set the message to ``||variables:Direction||``; this will send a direction command to the CuteBot.
```blocks
loops.everyInterval(100, function () {
- if (input.rotation(Rotation.Pitch) > 60) {
- radio.sendString("Backwards")
- }
-})
-```
-## Step 7 - Click "+" twice to show an else-if placeholder
-Click "+" at the bottom of the if-block twice to show an else-if placeholder
-```blocks
-loops.everyInterval(100, function () {
- if (input.rotation(Rotation.Pitch) > 60) {
- radio.sendString("Backwards")
- } else if (true) {
-
- } else {
-
- }
-})
-```
-## Step 8 - Add button A+B is pressed to go forwards
-Add ``||input:Input:button A+B is pressed||`` to the else-if and add a ``||radio:Radio:send string||`` block to send "Forwards"
-```blocks
-loops.everyInterval(100, function () {
- if (input.rotation(Rotation.Pitch) == 60) {
- radio.sendString("Backwards")
- } else if (input.buttonIsPressed(Button.AB)) {
- radio.sendString("Forwards")
- } else {
-
+let Direction = Stop
+ if (input.buttonIsPressed(Button.A)) {
+ Direction = Left
}
-})
-```
-## Step 9 - Add button A is pressed to go left
-Add ``||input:Input:button A is pressed||`` to the else-if and add a ``||radio:Radio:send string||`` block to send "Left"
-```blocks
-loops.everyInterval(100, function () {
- if (input.rotation(Rotation.Pitch) > 60) {
- radio.sendString("Backwards")
- } else if (input.buttonIsPressed(Button.AB)) {
- radio.sendString("Forwards")
- } else if (input.buttonIsPressed(Button.A)) {
- radio.sendString("Left")
-
- } else {
+ if (input.buttonIsPressed(Button.B)) {
+ Direction = Right
}
-})
-```
-## Step 10 - Add button B is pressed to go right
-Add ``||input:Input:button B is pressed||`` to the else-if and add a ``||radio:Radio:send string||`` block to send "Right"
-```blocks
-loops.everyInterval(100, function () {
- if (input.rotation(Rotation.Pitch) > 60) {
- radio.sendString("Backwards")
- } else if (input.buttonIsPressed(Button.AB)) {
- radio.sendString("Forwards")
- } else if (input.buttonIsPressed(Button.A)) {
- radio.sendString("Left")
- } else if (input.buttonIsPressed(Button.B)) {
- radio.sendString("Right")
-
- } else {
+
+ if (input.buttonIsPressed(Button.AB)) {
+ Direction = Forwards
}
-})
-```
-## Step 11 - Complete the if-block by adding the "Stop" radio message
-Complete the if-block by adding a ``||radio:Radio:send string||`` block to send "Stop"
-```blocks
-loops.everyInterval(100, function () {
if (input.rotation(Rotation.Pitch) > 60) {
- radio.sendString("Backwards")
- } else if (input.buttonIsPressed(Button.AB)) {
- radio.sendString("Forwards")
- } else if (input.buttonIsPressed(Button.A)) {
- radio.sendString("Left")
- } else if (input.buttonIsPressed(Button.B)) {
- radio.sendString("Right")
- } else {
- radio.sendString("Stop")
+ Direction = Backwards
}
+ // @highlight
+ radio.sendString(Direction)
})
```
-## Step 12 - Add radio send string "Rainbow" to on logo pressed
-To flash the Cutebot's lights, drag a ``||input:Input:on logo pressed||`` block onto canvas and use ``||radio:Radio:send string||`` to send "Rainbow"
+## 100ms Frequency @showdialog
+Your micro:bit will send a Direction message to your CuteBot every 100 milliseconds, that's 10 times a second. Wow, that's really fast, try saying forwards 10 times in 1 second.
+
+## Let's also send a "Rainbow" lights command to the CuteBot by using on logo pressed
+To flash the Cutebot's lights, drag a ``||input:Input:on logo pressed||`` block onto canvas and use ``||radio:Radio:send string||`` to send the variable ``||variables:Rainbow||``
```blocks
+// @highlight
input.onLogoEvent(TouchButtonEvent.Pressed, function () {
- radio.sendString("RAINBOW")
+ radio.sendString(Rainbow)
})
```
-## Step 13 - download and test
-Click ``|Download|`` to download your code onto your micro:bit to see it working
+## Download and test - good luck and happy racing!!!
+Click ``|Download|`` to download your code onto your micro:bit to see it working. Good luck and happy racing!
diff --git a/main.py b/main.py
new file mode 100644
index 0000000..f8d8acd
--- /dev/null
+++ b/main.py
@@ -0,0 +1 @@
+# leave empty
\ No newline at end of file
diff --git a/pxt.json b/pxt.json
index d4c0275..1286470 100644
--- a/pxt.json
+++ b/pxt.json
@@ -13,7 +13,8 @@
"CodeClubBadge.md",
"QuickDraw.md",
"CuteBotController.md",
- "tutorial-info-cache.json"
+ "tutorial-info-cache.json",
+ "main.py"
],
"testFiles": [
"test.ts"