Milk Jar Robot (#377)
* first draft * fixed code section * calibration * fix broken link
This commit is contained in:
parent
3f25c2a170
commit
2bec29bdd1
@ -19,6 +19,7 @@
|
||||
* [Duct tape wallet](/projects/wallet)
|
||||
* [Watch](/projects/watch)
|
||||
* [Inchworm](/projects/inchworm)
|
||||
* [Milk Jar Robot](/projects/milk-jar-robot)
|
||||
* [Milk monster](/projects/milky-monster)
|
||||
* [Timing gates](/projects/timing-gates)
|
||||
* [Compass](/projects/compass)
|
||||
@ -30,6 +31,7 @@
|
||||
* [Plot acceleration](/examples/plot-acceleration)
|
||||
* [Plot light level](/examples/plot-light-level)
|
||||
* [Plot analog pin](/examples/plot-analog-pin)
|
||||
* [Servo Calibrator](/examples/servo-calibrator)
|
||||
|
||||
## #reference
|
||||
|
||||
|
@ -110,6 +110,10 @@ basic.forever(() => {
|
||||
* When powered by USB, make sure that the servo moves when you tilt the board.
|
||||
* When powered by batteries **only**, make sure that the servo moves when you tilt the board.
|
||||
|
||||
## Calibrating
|
||||
|
||||
Using the [servo calibrator program](/examples/servo-calibrator) to determine the best angles to use in your make.
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
If your servo seems to sutter and stay stuck at a particular position, it means that it is not receiving enough power.
|
||||
|
@ -39,3 +39,13 @@ Here are some fun programs for your @boardname@!
|
||||
"url":"/examples/plot-analog-pin"
|
||||
}]
|
||||
```
|
||||
|
||||
## Actuators
|
||||
|
||||
```codecard
|
||||
[{
|
||||
"name": "Servo Calibrator",
|
||||
"description": "calibrates a servo",
|
||||
"url":"/examples/servo-calibrator"
|
||||
}]
|
||||
```
|
20
docs/examples/servo-calibrator.md
Normal file
20
docs/examples/servo-calibrator.md
Normal file
@ -0,0 +1,20 @@
|
||||
# Servo calibrator
|
||||
|
||||
```blocks
|
||||
let angle = 90
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
angle -= 5
|
||||
pins.servoWritePin(AnalogPin.P0, angle)
|
||||
led.stopAnimation()
|
||||
})
|
||||
input.onButtonPressed(Button.B, () => {
|
||||
angle += 5
|
||||
pins.servoWritePin(AnalogPin.P0, angle)
|
||||
led.stopAnimation()
|
||||
})
|
||||
basic.forever(() => {
|
||||
basic.showNumber(angle)
|
||||
})
|
||||
pins.servoWritePin(AnalogPin.P0, angle)
|
||||
basic.showString("Press A or B to change servo angle")
|
||||
```
|
@ -69,6 +69,10 @@ Fun games to build with your @boardname@.
|
||||
"name": "Inchworm",
|
||||
"url":"/projects/inchworm",
|
||||
"imageUrl":"/static/mb/projects/inchworm.jpg"
|
||||
}, {
|
||||
"name": "Milk Jar Robot",
|
||||
"url":"/projects/milk-jar-robot",
|
||||
"imageUrl":"/static/mb/projects/milk-jar-robot.jpg"
|
||||
}, {
|
||||
"name": "Milky Monster",
|
||||
"url":"/projects/milky-monster",
|
||||
|
53
docs/projects/milk-jar-robot.md
Normal file
53
docs/projects/milk-jar-robot.md
Normal file
@ -0,0 +1,53 @@
|
||||
|
||||
# Milk Jar Robot
|
||||
|
||||
### @description A half gallon milk jar robot
|
||||
|
||||
### ~avatar avatar
|
||||
|
||||
Make a funny Milk Jar robot!
|
||||
|
||||
### ~
|
||||
|
||||
https://youtu.be/Ah4fEbJtklU
|
||||
|
||||
## Duration
|
||||
|
||||
3 Activities, approx 30-45 min each based on familiarity with the coding concepts
|
||||
|
||||
## Materials
|
||||
|
||||
### Recycled
|
||||
|
||||
* 1 Milk Carton **without a screwable cap**
|
||||
* 2 Coffee stiring wood sticks
|
||||
* 2 Straws
|
||||
|
||||
### Electronics
|
||||
|
||||
* 1 @boardname@, battery holder and 2 AAA batteries
|
||||
* 3 Crocodile clips
|
||||
* 1 micro servo 9g SG90
|
||||
|
||||
### Tools
|
||||
* Scissors that can cut cardboard
|
||||
* Hol puncher (scissors will work too)
|
||||
* Glue gun
|
||||
|
||||
![Materials](/static/mb/projects/milk-jar-robot/materials.jpg)
|
||||
|
||||
## Preparation
|
||||
|
||||
* [Equip the microservo with crocodile clips](/device/servo)
|
||||
|
||||
## Activities
|
||||
|
||||
* [Make](/projects/milk-jar-robot/make)
|
||||
* [Code](/projects/milk-jar-robot/code)
|
||||
* [Connect](/projects/milk-jar-robot/connect)
|
||||
|
||||
### ~button /projects/milk-jar-robot/make
|
||||
|
||||
Let's get started!
|
||||
|
||||
### ~
|
73
docs/projects/milk-jar-robot/code.md
Normal file
73
docs/projects/milk-jar-robot/code.md
Normal file
@ -0,0 +1,73 @@
|
||||
# Code
|
||||
### @description code to make the Milk Jar Robot alive
|
||||
|
||||
### ~avatar avatar
|
||||
|
||||
Add code to make the Milk Jar Robot move.
|
||||
|
||||
### ~
|
||||
|
||||
## Duration: ~15 minutes
|
||||
|
||||
## Step 1: wire up the servo
|
||||
|
||||
Follow the instructions in [servo 101 manual](/device/servo) to connect the servo to the @boardname@.
|
||||
|
||||
https://youtu.be/m-HS8OyS0pw
|
||||
|
||||
## Step 2: code light sensor
|
||||
|
||||
Code the lightsensor on the @boardname@ to control the servo.
|
||||
|
||||
```blocks
|
||||
basic.forever(() => {
|
||||
led.plotBarGraph(
|
||||
input.lightLevel(),
|
||||
0
|
||||
)
|
||||
pins.servoWritePin(AnalogPin.P0, input.lightLevel())
|
||||
})
|
||||
```
|
||||
|
||||
https://youtu.be/Ah4fEbJtklU
|
||||
|
||||
It works but your servo might be trying to move too much. Let's calibrate it.
|
||||
|
||||
## Step 3: calibrate the servo
|
||||
|
||||
Download the [servo calibration program](/examples/servo-calibrator) to determine
|
||||
to opening and closing angles of the servo for your robot.
|
||||
|
||||
https://youtu.be/lZxWC82HDn0
|
||||
|
||||
We are going to map the light level range, ``[0, 255]`` to the
|
||||
angle range, ``[closed, opened]`` using ``pins.map``.
|
||||
|
||||
```blocks
|
||||
let angle = 0
|
||||
let closed = 0
|
||||
let opened = 0
|
||||
basic.forever(() => {
|
||||
led.plotBarGraph(
|
||||
input.lightLevel(),
|
||||
0
|
||||
)
|
||||
angle = pins.map(
|
||||
input.lightLevel(),
|
||||
0,
|
||||
255,
|
||||
opened,
|
||||
closed
|
||||
)
|
||||
pins.servoWritePin(AnalogPin.P0, angle)
|
||||
})
|
||||
// TODO: use the angle found at calibration!
|
||||
opened = 95
|
||||
// TODO: use the angle found at calibration!
|
||||
closed = 175
|
||||
```
|
||||
|
||||
|
||||
### ~button /projects/milk-jar-robot/connect
|
||||
NEXT: Connect
|
||||
### ~
|
28
docs/projects/milk-jar-robot/connect.md
Normal file
28
docs/projects/milk-jar-robot/connect.md
Normal file
@ -0,0 +1,28 @@
|
||||
# Connect
|
||||
|
||||
### ~avatar avatar
|
||||
|
||||
Remote control your Milk Jar Robot with another @boardname@
|
||||
|
||||
### ~
|
||||
|
||||
## Duration: ~30 minutes
|
||||
|
||||
You will need 2 @boardname@ for this part. By using the radio, we can make the Milk Jar Monster controlled by another @boardname@.
|
||||
Download the code below to the @boardname@ on the Milk Jar Monster and another "controller" @boardname@. Whenere ``A`` is pressed, the Milk Jar Monster will move once.
|
||||
|
||||
```blocks
|
||||
radio.onDataPacketReceived(({receivedNumber}) => {
|
||||
pins.servoWritePin(AnalogPin.P0, 0)
|
||||
basic.pause(500)
|
||||
pins.servoWritePin(AnalogPin.P0, 180)
|
||||
basic.pause(500)
|
||||
})
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
radio.sendNumber(0)
|
||||
})
|
||||
```
|
||||
|
||||
```package
|
||||
radio
|
||||
```
|
48
docs/projects/milk-jar-robot/make.md
Normal file
48
docs/projects/milk-jar-robot/make.md
Normal file
@ -0,0 +1,48 @@
|
||||
# Make
|
||||
### @description Building the cardboard Milky Monster
|
||||
|
||||
### ~avatar avatar
|
||||
|
||||
Turn a piece of cardboard into an milky-monster!
|
||||
|
||||
![Make](/static/mb/projects/milk-jar-robot/make.jpg)
|
||||
|
||||
### ~
|
||||
|
||||
## Duration: ~45 minutes
|
||||
|
||||
|
||||
## Step 1: Cutting the lip
|
||||
|
||||
https://youtu.be/1JbjOFft4Lc
|
||||
|
||||
## Step 2: Cutting the mouth
|
||||
|
||||
https://youtu.be/1oQC2pyTEQ4
|
||||
|
||||
## Step 3: Cutting the teeth
|
||||
|
||||
https://youtu.be/PBrtlf49aaY
|
||||
|
||||
## Step 4: Attaching the mouth
|
||||
|
||||
https://youtu.be/z1KWDi2T8OA
|
||||
|
||||
## Step 5: Attaching the mouth wood sticks
|
||||
|
||||
https://youtu.be/Wfr5Vf51-ZU
|
||||
|
||||
## Step 6: Mounting the servo
|
||||
|
||||
https://youtu.be/GsOP1S6cDjU
|
||||
|
||||
## Step 7: Connecting the mouth to the servo
|
||||
|
||||
https://youtu.be/pRAC2Ritgtk
|
||||
|
||||
|
||||
Well done! Let's move to programming the @boardname@ to move the mouth.
|
||||
|
||||
### ~button /projects/milk-jar-robot/code
|
||||
NEXT: Code
|
||||
### ~
|
BIN
docs/static/mb/projects/milk-jar-robot.jpg
vendored
Normal file
BIN
docs/static/mb/projects/milk-jar-robot.jpg
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 14 KiB |
BIN
docs/static/mb/projects/milk-jar-robot/make.jpg
vendored
Normal file
BIN
docs/static/mb/projects/milk-jar-robot/make.jpg
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 79 KiB |
BIN
docs/static/mb/projects/milk-jar-robot/materials.jpg
vendored
Normal file
BIN
docs/static/mb/projects/milk-jar-robot/materials.jpg
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 158 KiB |
Loading…
Reference in New Issue
Block a user