For this lab we created two different circuits that utilized a pseudo-analog output voltage with Pulse-width modulation and frequency modulation.
Part 1: Servo Motor Control with an Arduino
For the first part of the lab I used a potentiometer to control the angle of a servo motor. The code required us to include the servo library, then use analogRead() to get the value from the potentiometer and map it, so that the servo motor could move.
Part 2: Tone Output using an Arduino
For this part of the lab we used photocells to vary to tone output of a speaker. To code the Arduino, we used an analog input from the photocells and mapped the values to play a tone at varied frequencies.
Part 3: Creative Enclosure
For my creative enclosure I expanded on the first part of the lab by incorporating a photocell that controls the angle of the servo motor arm. I created a day and night simulator where the moon or sun comes up, depending on how much light the photocell is exposed to. When there is a lot of light the sun comes up but when there is little light, the servo rotates so that the moon is showing.