0
0
Raspberry Piprogramming~10 mins

Automated plant watering system in Raspberry Pi - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the GPIO library for Raspberry Pi.

Raspberry Pi
import [1] as GPIO
Drag options to blanks, or click blank then click option'
ARPi.GPIO
Bgpiozero
Ctime
Dos
Attempts:
3 left
💡 Hint
Common Mistakes
Importing unrelated libraries like 'time' or 'os'.
Using 'gpiozero' which is a different GPIO library.
2fill in blank
medium

Complete the code to set GPIO pin 18 as an output pin.

Raspberry Pi
GPIO.setmode(GPIO.BCM)
GPIO.setup([1], GPIO.OUT)
Drag options to blanks, or click blank then click option'
A17
B18
C27
D22
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong pin numbers like 17 or 22.
Not setting the pin as output.
3fill in blank
hard

Fix the error in the code to read moisture sensor value from pin 23.

Raspberry Pi
GPIO.setup(23, GPIO.IN)
moisture = GPIO.[1](23)
Drag options to blanks, or click blank then click option'
Aoutput
Bread
Cinput
Dinput_read
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'output' instead of 'input'.
Using non-existent methods like 'read' or 'input_read'.
4fill in blank
hard

Fill both blanks to turn on the water pump when soil is dry.

Raspberry Pi
if moisture [1] 0:
    GPIO.output([2], GPIO.HIGH)
Drag options to blanks, or click blank then click option'
A==
B!=
C18
D23
Attempts:
3 left
💡 Hint
Common Mistakes
Using '!=' instead of '=='.
Using wrong pin number for pump.
5fill in blank
hard

Fill both blanks to create a dictionary of sensor readings with pin as key and value as moisture.

Raspberry Pi
sensor_data = {[2]: [1] for [3] in [23, 24, 25]}
Drag options to blanks, or click blank then click option'
A{
BGPIO.input(pin)
Cpin
D}
Attempts:
3 left
💡 Hint
Common Mistakes
Using list brackets instead of dictionary braces.
Using wrong variable names.