Week 10 Assignments - Output Devices
Group Assignment
The group assignment for this week was to:
- Measure the power consumption of an output device.
- Document your work on the group work page and reflect on your individual page what you learned.
Outcomes
Link to Group Site
The group assignment page for this week is on the 2025 Charlotte Super Fab Lab group site for Week 10 - Output Devices.
What Was Learned
In the group assignment, we considered power consumption of LEDs - including one standard LED and 2 neopixels. We were able to measure the power consumption for the LEDs across different RGB settings to drive the individual R, G, and B component channels. This provided us experience on:
- How to use test equipment to measure power consumption
- What to look for in power consumption as part of assignments and project work going forward
Individual Assignment
The individual assignment for this week was to:
- Add an output device to a microcontroller board you’ve designed and program it to do something.
Outcomes
In order to explore different outputs, I used the microcontroller board that I developed previously in Week 8 - Electronics Production.
I selected an LED and a servo motor to test as outputs. The LED was integrated onboard as part of the previouly completed development board. The servo motor used direct connections to the input connectors on the development board.
Integrated LED
The LED connection was integrated into the design of the Xiao ESP32C3 microcontroller board that I designed. One side of the LED has a connection to the XIAO board on pin D6 (GPIO21). This connection serves provides a driving voltage for the LED. The other side of the LED is connected to a 50 ohm resistor, as appropriate for the LED, with 3.3V XIAO power. The XIAO can then drive the state of the LED with output on pin D6 (HIGH for on, and LOW for off).
The resistance level (50 ohm) was determined by the characteristics of the LED. From the LED datasheet, the forward voltage drop of the LED is 1.8V. With the 3.3V signal from the XIAO board, there would be a 1.5V drop across the resistor in series with the LED. From the datasheet, the LED forward current rating is 30mA. In order to maintain appropriate current level for the LED, using Ohm's law (V=IR) the resistance needed to be (voltage drop / current level), 1.5/.03 = 50, or 50 ohms.
I wrote a program from scratch using C code and the Arduino IDE, in order to exercise the onboard LED. There are two main parts.
- Blink the LED 5 times on setup - in general, this can be a useful visual signal to know that our program has loaded and is starting on the board and may be helpful to include in other programs later
- Connect the state of the LED to the onboard pushbutton that was developed in the Week 9 Assignments - Input Devices. When the button is not pressed, the onboard LED is off. When the button is pressed, the onboard LED is on.
Onboard LED - Blink Sequence on Startup and Button Lightup Response
Servo Sweep with LED Transition
For the second output device, I selected a micro servo. I developed a progam that sweeps the servo position back and forth continuously. When a sweep in a particular direction reaches the end, the onboard LED blinks once to indicate the transition to the other direction.
There are different types of servo motor, with variations on how they operate. The main types are:
- Positional Rotation Servo - perhaps the most common type, the positional rotation servo rotates to and holds a specific angle within a limited range (often 180 degrees of the home position). For this type of servo, the control signal determines the angle being held.
- Continuous Rotation Servo - the continuous rotation servo does not have a limit on angle of rotation and can rotate freely. For this type of servo, the control signal determines the speed and direction of rotation.
I used a positional rotation servo, which can be set to a specific angle of rotation to hold. The control signal determines the angle by sending a pulse of a specific width (e.g., 1ms pulse for 0 degrees, 2ms pulse for 180 degrees).
I connected the servo to the XIAO board using the input connectors, as follows:
- The servo power lead (red wire) was connected to the XIAO 5V output
- The servo GND lead (brown wire) was connected to the XIAO GND output
- The servo signal lead (orange wire) was connected to the XIAO output pin D10
The development board was designed with breakout connections from the microcontroller board for power, ground, and I/O pins, in order to support a variety of potential use cases. For this activity, the servo was connected with individual jumper wires for power, ground, and control signal. While jumper connections may be serviceable for more temporary, early stage prototyping or learning activities, it is important to note that they may be less appropriate as part of more permanent later stage and final designs, such as for the final project. For later stage, longer term design, dedicated connectors for peripherals may be more appropriate, such as a single conenctor block that groups power, ground, and I/O for peripheral connection.
I wrote the servo control program in C using the Arduino IDE. The Arduino IDE provides a set of example programs for outputs. I adapted the Sweep example program to control the servo motor. A number of revisions and modifications were made.
The example program used the Servo.h
library as support to control the servo motor. Compiling the program gave a number of errors related to the library. I conducted some basic research and found that a special version of the servo library is needed for ESP32 type boards. I located the correct library ESP32Servo.h
and installed it in the Arduino IDE.
To signal the end of a sweep in one direction and a change to a sweep in the opposite direction, I added a blink of the onboard LED after the end of each sweep.
Servo Sweep with LED Blink on Direction Change