Milk Jar Robot (#377)

* first draft

* fixed code section

* calibration

* fix broken link
This commit is contained in:
Peli de Halleux
2017-03-26 21:22:40 -07:00
committed by GitHub
parent 3f25c2a170
commit 2bec29bdd1
12 changed files with 242 additions and 0 deletions

View 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
### ~

View 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
```

View 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
### ~