Soil - moisture (#418)
* updated servo calibrator * updated plot analog pin example * updated servo example * first drop of soil moisture * updated picture * fixing macros * update code section * 5 seconds * adding soil moisture * fixing links
This commit is contained in:
@ -1,10 +1,18 @@
|
||||
# Plot Analog Pin
|
||||
|
||||
Use this program to graph the analog value on pin ``P0``, ``P1`` or ``P2``.
|
||||
Press ``A`` to scroll the value on the screen.
|
||||
|
||||
```blocks
|
||||
let reading = 0
|
||||
basic.forever(() => {
|
||||
reading = pins.analogReadPin(AnalogPin.P0)
|
||||
led.plotBarGraph(
|
||||
pins.analogReadPin(AnalogPin.P0),
|
||||
reading,
|
||||
1023
|
||||
)
|
||||
if (input.buttonIsPressed(Button.A)) {
|
||||
basic.showNumber(reading)
|
||||
}
|
||||
})
|
||||
```
|
||||
|
@ -1,14 +1,21 @@
|
||||
# Servo calibrator
|
||||
|
||||
Use this program to calibrate the angles of a servo.
|
||||
Press ``A`` to reduce the angle by 5 and ``B`` to
|
||||
increase it by 5.
|
||||
|
||||
The current angle is displayed on the screen
|
||||
in a loop.
|
||||
|
||||
```blocks
|
||||
let angle = 90
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
angle -= 5
|
||||
angle -= Math.max(0, 5)
|
||||
pins.servoWritePin(AnalogPin.P0, angle)
|
||||
led.stopAnimation()
|
||||
})
|
||||
input.onButtonPressed(Button.B, () => {
|
||||
angle += 5
|
||||
angle += Math.min(180, 5)
|
||||
pins.servoWritePin(AnalogPin.P0, angle)
|
||||
led.stopAnimation()
|
||||
})
|
||||
@ -16,5 +23,4 @@ basic.forever(() => {
|
||||
basic.showNumber(angle)
|
||||
})
|
||||
pins.servoWritePin(AnalogPin.P0, angle)
|
||||
basic.showString("Press A or B to change servo angle")
|
||||
```
|
||||
|
Reference in New Issue
Block a user