Connor Bergs
Created May 17, 2022

Micro:bit smart plant controller

This project uses the Micro:bit to measure soil moisture and tells you whether or not you should water your plant.

44

Things used in this project

Hardware components

BBC micro:bit board
BBC micro:bit board
×1
Alligator Clips
Alligator Clips
×2
AA Batteries
AA Batteries
×2
Harness Board Nails, Nickel Plated Steel
Harness Board Nails, Nickel Plated Steel
×2

Software apps and online services

MakeCode
Microsoft MakeCode

Story

Read more

Schematics

Arial view of setup

Here is a picture of how I connected everything

Code

Code used in this project

JavaScript
I wrote this code in Microsoft Makecode
let reading = 0
led.setBrightness(64)
basic.forever(function () {
    pins.analogWritePin(AnalogPin.P1, 1023)
    reading = pins.analogReadPin(AnalogPin.P0)
    pins.analogWritePin(AnalogPin.P1, 0)
    led.plotBarGraph(
    reading,
    1023
    )
    if (input.buttonIsPressed(Button.A)) {
        basic.showNumber(reading)
        if (reading < 700) {
            basic.showString("Water your plant")
        }
        if (reading > 701) {
            basic.showString("Your plant has enough water")
        }
    }
    basic.pause(5000)
})

Credits

Connor Bergs

Connor Bergs

1 project • 0 followers

Comments