Milk Jar Robot (#377)
* first draft * fixed code section * calibration * fix broken link
This commit is contained in:
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!
|
||||
|
||||

|
||||
|
||||
### ~
|
||||
|
||||
## 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
|
||||
### ~
|
Reference in New Issue
Block a user