moister-detection-2/README.md
2026-09-23 10:07:52 -06:00

27 lines
939 B
Markdown

# Moisture Detection 2
The moisture sensor is back, and now it sends a time with every level.
## What is what
| File | |
| :--- | :--- |
| `moisture.c` | Parts B and C: your code goes here, at each `YOUR TASK` |
| `api/` | the sensor library; do not edit it |
## What to do
2. **Part A.** In `moisture.c`, write `classify()`, then finish the loop in `main()`: skip sensor faults and store every other reading in `times[]` and `levels[]`. Then write `count_in_band()`, `index_of_max()`, and `average()`. You are done when the `check:` line says PASS for `./moisture` and for
`./moisture 7`.
3. **Part B.** Run `./moisture 7 14`. Fourteen readings do not fit in ten slots: print the "dropped" line instead of writing past the end.
## Build and run
```
gcc -std=c17 -Wall -Wextra -o moisture moisture.c api/moisture_sensor.c
./moisture
./moisture 7
./moisture 7 14
```
For Part B, add `-fsanitize=address -g` to the moisture line.