Sometimes we need a form of visual feedback regarding the control variable; in other words, some manner of readout. In this case, we can make a simple “LED bar” to indicate the motor speed; the faster the speed, the wider the bar. There is no need to re-invent the wheel as we’ve done this before. Consider adapting the
lightLEDsBar() function from the Arduino Analog Input exercise. It will require four LED drivers connected to port B.
Finally, let’s consider setting the motor speed in accordance to some environmental variable such as temperature or light level instead of using a manually controlled potentiometer. The potentiometer can be replaced with a simple sensor such as the LM34 for temperature or a resistor and photoresistor (CdS cell) voltage divider to sense light levels. It will be relatively easy and safe to create extreme changes in light level using a flashlight and a finger (to cover and block the light). The range of the temperature sensor voltage will be comparatively narrow, so a different range of mapping will probably be in order. You may also wish to mount the temperature sensor away from the other circuit elements in order to isolate them from excessive heat and cold. No open flames should be used in lab to create heat!
Include your code and a proper schematic, as usual, along with a description of how you tested the result.