feedmenowThis guide is aimed at children aged 7 and over. Under 10’s should ask a grown up to help them.

This guide will show you how to use Scratch, a Picoboard and a Moisture sensor to test if a plants soil is dry and make a character say something in response.

To download a .pdf version of this guide click here.

feedmenow s shot

To do this activity you will need

  • Raspberry Pi connected with keyboard, mouse & monitor.
  • PicoBoard
  • Moisture Sensor

You can use Picoboard sensing Blocks to tell Scratch about events happening in the physical world outside of the computer.

.picoblock sensors in use

The Picoboard is a child friendly Microcontroller to be used with Scratch.

Basically it’s a mini computer on a chip, that let’s Scratch sense things in the real world.

In a way, Picoboards give Scratch senses.

It gives you a range of different ways to sense events in the real world and program Scratch to respond to them.

Connect your Picoboard to your Raspberry Pi using a Mini- USB cable.

piconewSlide1_img

Clip the two crocodile clips onto the two small pins on your moisture detector and plug the socket into input ‘A’ on your Picoboard.

moisture_sensor

Open Scratch.

Find the Picoboard sensor blocks at the bottom of the blue ‘Sensing’ palette. You can choose which sensor to have Scratch use by clicking on the little triangle and selecting a sensor from the block. We will choose ‘Resistance A’.

sensor blocks

If you tick the box to the left of the Picoboard blocks in the ‘sensor’ palette, Scratch will show you which a number from 0 to 100 for each of the sensors you are using.

picoblock monitors

Place your sensor in different materials, e.g. water, dry soil and wet soil and observe how the number changes.

This sensor tests how wet something is by trying to pass electricity through it. Electricity is sent from one of one end of the sensor and tries to jump to the other end.

Resistance is a number given to how difficult electricity finds it to move through different materials. The higher the resistance of a material the less electricity will pass through it.

We also know that electricity finds it easier to pass through materials if they are have water in them.

The number reading from sensor ‘A’, is called ‘resistance’. The higher this resistance number is, the less electricity is passing through the soil.

Use your moisture sensor by placing inserting it into different soils and reading the ‘Resistance A’ number on the Scratch stage. Test what the resistance number is for wet soil and dry soil.

Fill in the gaps below to complete the sentences using the words ‘Wet’ or ‘Dry’.

_ _ _  soil is very conductive, electricity passes through it well and it has low resistance.

_ _ _  soil is not very conductive, electricity can’t pass through it very well and it has high resistance.

Open Scratch

Use blocks like these you can make Scratch say “Feed me now” when soil is too dry for a plant.

feedme09

Doubleclick on a sprite to select it.

Make sure you are using the ‘scripts’ panel, not ‘costumes’ or ‘sounds’.

Click to open the orange ‘Control’ script blocks.

Drag out a ‘When Green Flag Clicked’ block and place it in the middle of the script space.

feedme01

Click to open the orange ‘Control’ script blocks.

feedme02

feedme03

Drag out an ‘IF’ block and place it inside the ‘Forever’ block.

When we program sprites, we can use this block to make them check if something is true and then do something else. For example, “If the sprites size is over 100, then move forwards 20.”

Click to open the green ‘Operators’ script blocks.

Drag out a ‘>’ block and place it inside the slot in the top of the ‘IF’ block.

feedme04b

The ‘IF’ block has two places for other blocks to go a ‘Test slot’ and an ‘Instruction slot’.

The ‘IF’ block will test if something is true and then carry out an instruction if it is true.

We place the ‘test’ script in the slot in the top of the ‘IF’ block and the instruction blocks inside the ‘IF’ block.

We need to tell our sprite how to test if something is true. We will use a ‘More Than’ block to tell it how to test.

This can be used to test if the number value of one thing is more than another thing. This block has two slots to put things in. If the thing in the 1st slot is bigger than the thing in the 2nd slot, then the sprite will carry out the instruction inside the ‘IF’ block.

Click to open the blue ‘sensing’ script blocks.

Drag out the rounded ‘sensing’ block and drag it into the 1st slot in the green ‘<’ block.

feedme05

We need to tell our sprite which sensor input to test. Click on the small upside down triangle on the blue ‘sensing’ block and select ‘Resistance A’.

feedme07

Click on the 2nd slot in the green ‘<’ block and type 50.

feedme08

This code tests ‘If’ the resistance number for the soil is over 50.

Drag out a ‘Say’ block and place it inside the ‘IF’ block.

feedme09

Think what a plant might say if its soil was dry and it needed a drink. Click in the slot in the ‘Say’ block and write some words for the plant to say if it’s soil is dry.

Click on the Green Flag and insert the sensor into some soil. If the soil is dry, your sprite should say something.

More Ideasfeedmenow

You might want to change the number to the right hand side of your green ‘>’ more than block so that your sprite says something when the soil is drier or wetter.

You could add other ‘IF’ block tests to make your sprite say different things depending on how wet or dry the soil is.

How else might you be able to change how your sprite looks, to let people know that the plant needs watering?

Look in the ‘Looks’ script blocks for some inspiration.