"Microcontroller-Based Mechatronic Design"


Each group must design, build, test, and demonstrate a device controlled by one or more microcontrollers, including a PIC microcontroller. Non-PIC controllers (e.g., Arduino, ESP, STM32 Blue Pill, Raspberry Pi, BeagleBone, Edison, TI MSP432 Launchpad, PLCs, FPGAs, DSPs, etc.) are allowed, but at least one PIC running PicBasic Pro must be involved and be an integral/functional/useful part of the system (e.g., it can't just be replaced by a wire). The PIC must also be interfaced to any alternative controller(s).

The device should have functioning elements in all six categories listed below. The device will be rated (graded) based on the level of functionality achieved in each category. There will also be grading adjustments for qualitative attributes and how well the project is documented.

You are allowed to use circuits and code you find on the Internet or in other books, but make sure you have a full understanding of what the code or circuit does. You should also "add value" to what you use by incorporating it into your system creatively and effectively. Also, make sure you cite in your report any sources of any code or circuits you use.

NOTE - the choice of your project concept could have a large impact on the grade you receive; so please evaluate your alternative concepts carefully, based on the grading criteria below.

Project Requirements

Each group must present the following over the course of the project:

Each of these is described in detail below. See the syllabus for due dates.

We expect each group to be creative in coming up with a unique "device" that performs some useful function. Past project and alternative ideas can be found at Please choose an "appropriate" project concept, and avoid project ideas involving alcohol or drugs, weapons, anything illegal, explosives or fire, anything dangerous (e.g., electrocution or finger loss possible), etc.


The proposal must contain:

You should consider the proposal as a preliminary draft for portions of the final design report. If you do a good job with the proposal and create high quality illustrations and diagrams, you will be able to reuse the material in your final report.

Please do not bind or cover the pages of the report in any way. We want single-sided paper with a single staple or small binder clip in the top-left-hand corner only. Also, the proposal must be free from spelling and grammar mistakes.

Group Design Notebook

The design notebook is a loose leaf binder containing notes, sketches, schematics, documents and designs, separated by tabs based on the project deliverables listed on the syllabus. The design notebook will be reviewed and scored by the TA in Lab the weeks deliverables are due. The design notebook is not turned in at the end of the semester. Only the final report is submitted at the end of the semester.

Required Functional Element Categories

Your device should contain functioning elements in each of the six categories listed below. The examples under each element category are generally listed in order of increasing rating score (see below), depending on how you use and what you do with the element. Other components not listed as examples below are acceptable and encouraged. Note - you cannot receive credit for any category until you have a device that is mostly complete. You must have a functioning device, not just a collection of independently functioning elements. Also, all category components must be interfaced to a PIC or alternative controller (e.g., a power switch or a switch hard-wired to a motor does not count as manual data input). Having several different components in a single category can help your rating, but quality is more important than quantity.

  1. Output Display
  2. Audio Output Device
  3. Manual User Input (for interaction with the user)
  4. Automatic Sensor (for response without user input)
  5. Actuators, Mechanisms & Hardware
  6. Logic, Processing, and Control; AND Miscellaneous (functional elements not covered in the categories above)

Functional Element Category Ratings

The group's grade for the project will be based on the device's performance in each functional element category listed above (A, B, C, D, E, F) and on several grading adjustments described below. The rating for each category will be a number between 0 and 20 based on the following benchmark values:


Description of performance


nothing implemented (built, wired, interfaced, programmed).


something implemented, but non functional.


something implemented (i.e., has some level of functionality and is interfaced to the PIC or alternative controller), but not functioning as designed in a repeatable and reliable way.


something functioning as designed (i.e., performs some intended, useful function) and repeatable (i.e., it works every time), but did not require much research or effort on your part (e.g., you purchased something requiring very little interfacing and work, or you are using something presented in detail in class or Lab).


something functioning as designed and repeatable, and required significant research and effort on your part (e.g., you built something discussed in the text book, but not presented in detail in class or Lab, that required significant research and effort).


something functioning as designed (i.e., performs some intended, useful function) and repeatable, and required substantial independent research and effort on your part (e.g., you built something requiring knowledge and skills not presented in the textbook or used in Lab).

Each category will receive a rating, and the base project score will be the sum of the six ratings. For example, if the project is rated 12 for category A, 14 for B, 10 for C, and 10 for D, 19 for E, and 15 for F, the base project score would be 80.

The ratings are based on not only only what components you use, but also on the relevant and interesting things you do with the components through software and integration.

NOTE: These ratings are somewhat qualitative, so official scores will not be released until the end of the semester, after the instructor and TAs meet to discuss all of the results. But if your device functions well in all of the categories listed above, and some or all of the functional elements required significant research and/or work on your part, you can expect a high rating score.

Final Design Report

The final report is due in class the last Friday of the semester. Please do not bind or cover the pages of the report in any way. We want single-sided paper with a single staple or small binder clip in the top-left-hand corner only. Do not turn in your design notebook with the final report. The design notebook has already been checked throughout the semester, and it was mostly just for your benefit.

The report must include the following sections, free from spelling and grammar mistakes:

If anything is not done as described above, there will be deductions.

After looking at the figures and illustrations, and after reading the BRIEF and CONCISE descriptions in "Design Summary" and "System Details," the reader should be able to quickly and fully understand what your device is, what it looks like, what it does, and how it functions (without seeing a demonstration of the actual device).

Please use software tools for all work. Here are some recommended programs:

Here are some examples of elements from previous student reports:

And some example full reports can be found on the video demonstrations page. However, you should create your report based on the detailed requirements listed above, and not based just on the examples provided (which are not necessarily perfect or complete).

Be sure to cite sources (URLs or book bibliographies) for any circuits or code created by others and used in your design (even if modified).

Grading Adjustments

The base project score (the sum of the category ratings) will be adjusted by the following grading adjustments. The "qualitative adjustments" are judged by Dr. Dave, the TAs, and your classmates during the final project demonstrations in your scheduled Lab section meeting in the last week of the semester.


qualitative adjustments:



Additional Information:

Also, the group will have to multitask, accomplishing various design and testing steps in parallel (e.g., do not wait for the microcontroller to get programmed before testing the motor, input circuits, sensors, etc.).

Lessons Learned From Past Students:


  1. Start everything earlier than you think you should, especially part and device fabrication. Everything will take much longer than you think.
  2. Schedule and manage all of the stuff that needs to get done, allocating lots of time for everything, especially testing and debugging. Use a Gantt chart and elect somebody to be the team leader to delegate tasks and keep things on schedule.
  3. Work on all mechanical stuff and build things early in the semester (before you learn about microcontrollers), so you can focus on the electronics and microcontroller stuff later in the semester.
  4. Complicated mechanical devices can be a big pain and don't give you much reward in project grading. Keep things as simple as possible.
  5. Research and order all of your parts and devices very early and very carefully. Shipping can be expensive when stuff is needed fast.
  6. Order parts very early, and buy two (or more) of everything, so you will always have backup copies (e.g., if something gets damaged ... which seems to happen often).
  7. Be sure to have fall-back plans to reduce complexity or scale back on ambitions if necessary (i.e., make sure your design in "flexible").
  8. There are lots of good resources online for helping with different project stuff. Keep searching.
  9. Check out Dr. Dave's websites periodically through the semester. They contain lots of good resources and advice to save you a lot of time.
  10. Research and buy stuff on Ebay as much as you can to save money.
  11. Work late at night (especially Friday) or early morning (especially Sunday), when the Lab is not busy.
  12. Get help from classmates and past students. They will often know the "details" better than Dr. Dave or the TAs.
  13. Try to get ahead in your other classes leading into the finial weeks of the semester to give you more time to work on last-minute project stuff ... and there will be lots of this.
  14. Realize that everything will take much more time than you think, especially the system integration stuff after everything has been tested separately.
  15. Testing individual components and subsystems is just half the project. Don't underestimate how long it takes to assemble and test the entire integrated system.
  16. Sometimes you can get help by posting questions on online product and support forums.
  17. Demonstrate to the TAs and video-record functionality often in case things don't work later.
  18. Don't get discouraged ... unforeseen and difficult problems will come it, but you will find a way to manage or get through them. Keep a positive attitude.
  19. Make sure you get one of the early bird awards ... this can help you project grade quite a bit.
  20. It is a group project ... don't assume individuals will get their parts done and be prepared and willing to help.
  21. Be friendly and helpful to all of your classmates and you will get lots of help and friendship in return.
  22. Read and heed all of the lessons learned from past students.
  23. Use components recommended and used by past students successfully.
  24. Ordering stuff from AliExpress and other Chinese retailers is cheap, but delivery can take a long time.
  25. Use the 3D printing Lab to make parts (especially complicated parts) ... this can save a lot of time and money.

Components and Devices:

  1. If using an LCD, make sure you have a pause at the beginning of the program to let it warm up first. Also, backlit LCDs (e.g., white on blue) provide a much better display than the standard black on green LCDs. Also, electrically insulate the LCD from any metal plate or box it might be mounted to.
  2. Make sure you include a 10-20k pot with you LCD to be able to adjust contrast.
  3. If you plan to use Lcdout, make sure the LCD has a driver chip compatible with PicBasicPro (most have this).
  4. If you are using a serial LCD, make sure you use the proper Serout baud rate and use the formatting syntax for Serout, not Lcdout (e.g., # instead of DEC for number display).
  5. Passive Infrared (PIR) motion detectors are very sensitive and require absolute still during start-up calibration, and they can be unreliable. Don't use PIR sensors!
  6. If using stepper motors, make sure you order drivers that work with your motors (e.g., based on current and unipolar vs. bipolar).
  7. To move a stepper motor at a fast speed, you need to accelerate gradually to ramp up the speed; otherwise, steps will be missed (and the motor won't move properly, if at all).
  8. MOSFETs can use different pinout than BJTs ... be sure to read the datasheet carefully before making any connections.
  9. MOSFETs do not switch off unless the gate pin is grounded ... it doesn't switch off by just removing voltage.
  10. Use relays instead of transistors whenever you can, and keep the high-current side isolated (no common ground) from the signal side. Some relays will need a transistor or smaller relay attached to a microcontroller to provide enough switching current.
  11. If you try to build your own H-bridge (which isn't wise), use MOSFETS and/or relays instead of BJTs.
  12. RC servos require a constant stream of pulses while reaching a position, and to hold torque in a position.
  13. If you need to modify an RC servo motor to turn continuously, you can find instructions online for how to do this.
  14. Make sure you have flyback protection, with diodes, on all inductive loads (motors, solenoids, heaters, etc.). If switching an AC load, a high-wattage resistor in parallel with the load can help provide flyback protection.
  15. Using a capacitor across the leads of a dc motor can help limit power supply voltage fluctuations that might cause microcontrollers to reset.
  16. Make sure you order and test motors as early as possible so you will have enough time to get replacements if you find out you need more torque (or if you find out something else is wrong).
  17. You can't control the displacement of a dc motor simply by turning it on for a fixed amount of time. It won't turn the same amount every time, and from one day to the next, and depending on the strength of the batteries, etc.
  18. Stepper motors can get very hot if you keep the coils energized ... turn the coils off after each motion if possible.
  19. A cheap or used cordless drill (with integral gear motor) offers good torque at very low cost.
  20. Mountain States Electronics is a good place to order components and get information and advice locally. They stock many components you will need in your projects. Ordering online can take much longer and is usually more expensive (especially with shipping charges).
  21. Sparkfun has a warehouse in Boulder; so if you need parts quickly, you can order them online for pickup the same day. This will also save on shipping costs.
  22. Sparkfun is a great resource because they offer free technical support for all of their parts, and they can offer advice when deciding what to purchase.
  23. Many local industrial supply companies (e.g., plastics and metals suppliers) have scrap bins from which you can get free supplies.
  24. If you can't figure out how to make a device work, call the company who manufactures it for help. Sometimes a phone call can save hours or days of work.
  25. Arduinos can be very useful to complement PICS in your design. There are lots of code and wiring diagrams examples available online.
  26. If your audio is not loud enough, a power transistor can be used to boost the sound to a speaker.
  27. Solenoid valves sometimes require pressure on the inlet for them to open easily; if not, they might require significant current to actuate.
  28. Make sure you mount motors with stiff, strong, and adjustable (if possible) brackets.
  29. If using a digital compass, make sure it is as far as possible from electronics and actuators and mount it as high as possible to minimize interference.

Circuit Construction and Debugging:

  1. If you have multiple voltages in your design, be very careful to not apply a large voltage (e.g., 12 V) to digital circuits (e.g., the PIC). This will definitely cause damage.
  2. Before wiring circuits, draw detailed wiring diagrams first (e.g., using the free ExpressSCH software tool). You need to do this anyway for the final report, and they will be very useful as you build and debug circuits.
  3. Keep printouts of detailed schematics, pin-out diagrams, and datasheets for all components and circuits in you project.
  4. When your assembled circuits are not working, use the continuity-check feature of the multimeter to ensure all wiring and connections between source and terminus pins are good, and make sure there are no shorts between adjacent pins.
  5. Carefully check all component pin-out diagrams and other datasheet info before wiring or connecting anything.
  6. Make sure you have capacitors and flyback diodes everywhere you should (e.g., 0.1 μF across power and ground of every IC, especially the PICs).
  7. If you have trouble with some inputs triggering due to noise or interference, sometimes pull-down resistors to ground can help limit this.
  8. Follow all of the other troubleshooting advice in Section 15.5 of the Lab Book.
  9. Use large capacitors across power and ground of anything that draws large and/or spiking current, and across your main power supply (especially if using an AC/DC adapter, batteries, of a power supply with no output capacitors).
  10. Check all wiring carefully before connecting power to prevent damage to components.
  11. Always disconnect power when working on circuits (e.g., when moving wires or adding or removing components).
  12. Soldered printed circuit boards (PCBs) or protoboards are much more reliable than breadboards.
  13. If you decide to wire up a protoboard or printed circuit board (PCB), keep your breadboard intact (and buy extra components if necessary) if case things don't work out.
  14. Some breadboards are divided and require wire bridges to continue the power and ground buses down the length of the board.
  15. If you solder up a protoboard or PCB, purchase your own soldering iron. Also, check all of your connections carefully before applying power to your soldered circuits in case there are shorts. And be very careful to not damage components (see Lab 15 for advice on how to solder properly). Use IC sockets to prevent damage to ICs and to allow easy removal.
  16. Use more than one color wire to help keep things more organized and easier to debug.
  17. Physically label all key wires in your design so they don't get attached to the wrong things.
  18. Use ribbon cables and connectors to allow easy disconnects and to help organize wiring.
  19. Keep large magnetic field stuff (e.g., solenoids) away from your circuits to reduce electromagnetic interference.
  20. Always ground yourself to prevent electrostatic discharge when handling delicate components (e.g., MOSFET devices).
  21. Make sure all wires and circuit boards are well insulated when mounting them to surfaces.
  22. When joining two wires (e.g., by twisting them together), it is a good idea to use heat shrink-wrap tube to secure and protect the connection.

PIC, Arduino, and Software:

  1. Start your code as simply as possible (e.g., blink program) and add only a small piece at a time. Take "baby steps!"
  2. Early in the semester, but an Arduino kit and work through the example codes and circuits to help you to learn the Arduino environment and to develop basic circuit and programming skills.
  3. Use only the PIC16F88 when possible (since that is what is used in Lab). Other PICs can require more research and headaches. Take advantage of the free sample offer on the Microchip website and request lots of spares.
  4. Read and try to understand the intro sections of the PicBasic manual, Chapter 7 in the textbook, and the PIC exercises in the Lab book before you start programming. This will save you a lot of time in the long run.
  5. Allocate lots of time to debugging and testing of your code.
  6. Implement an LCD early in your work (even if your project does not require one). It will be very helpful during debugging and testing.
  7. Keep a printout handy for the pin-out of every PIC you are using.
  8. Using multiple PICs, each doing something simple, is easier to program and manage than a single PIC trying to do everything; although, it can be difficult to coordinate everything if they all need to communicate back and forth. Be sure to clearly label the different PICs to make it easy to tell them apart as you make changes to code.
  9. Always be careful to plug in the PIC to your board in the right direction to prevent damage.
  10. Make backup copies of working versions of microcontroller code (and even a programmed microcontroller) before making any changes.
  11. Read in the PicBasicPro manual the details for all commands you plan to use. This will save you a lot of time in the long run.
  12. If a microcontroller's pin can't output enough current (e.g., to turn on a relay), use a transistor or a relay.
  13. If running into memory problems (exceeding capacity), consider an 18-series PIC instead of a 16-series PIC.
  14. If getting lots of page boundary warning messages, don't worry (see Section 2.5.3 in the PicBasic manual). You can disable these messages by adding the following command at the top of your program: @ ERRORLEVEL -306
  15. Pull-down resistors on lines between microcontrollers can help improve the reliability of the connections.
  16. If using serial communication, make sure the Serin device is listening before the Serout device starts talking, and make sure both devices are set up with the same baud rate. Also, make sure all of your syntax is correct with both commands (e.g., don't forget the "#" prefix to send a variable's value).
  17. Use separate digital I/O handshaking lines to help synchronize timing of serial communication, and use the timeout feature (e.g., with the Serin2/Serout2 commands) if it is possible to miss or not have a signal.
  18. When using serial communication, consider adding a modifier character at the beginning of each transmission so the the receiver will know where the data starts (in case timing isn't correct) and/or use a time-out feature in case data is not received properly or in a timely manner.
  19. If you have devices that use I2C communication, use an Arduino (if easy-to-use Arduino software libraries are available) instead of a PIC and send the data to the PIC serially if necessary.
  20. The Sound command parameter is not directly related to music note frequencies. Here is a table of some example note values:
    Do=94, Re=98, Mi=102, Fa=103, So=106, La=108, Ti=110, Do=111
    For more info, see: Where Math Meets Music.
  21. The Pot command can be difficult to calibrate. Consider using an A/D converter input instead.
  22. Microcontroller output pins and ports have current limitations. If things don't work properly as you add more components (e.g., additional LEDs), it might be because you are exceeding the total current capacity. Also, microcontrollers can typically sink more current than they can source, so it is better to turn stuff (e.g., LEDs) on with negative logic.
  23. Use the Freqout command instead of the Sound command to easily generate music note frequencies.
  24. Use the multimeter and oscilloscope to probe all of your microcontroller pins to make sure they are going high and low as desired.
  25. Schmidt triggers are useful to clean up noisy digital signals.
  26. When attaching outputs from an Arduino to the input of a PIC, sometimes a pull-down resistor can help.
  27. Be careful with variable types when using Arduino C. If a function returns a certain type, make sure the variable storing the result is the same type.
  28. Use an Arduino and C if you need to do floating point calculations.
  29. Arduinos can be purchased much more cheaply from Newegg than Radio Shack.
  30. The MIT App Inventor provides an easy way to develop an app that can communicate with Arduinos and Raspberry Pis.

Power supply:

  1. Shop for power supplies and chargers at the CSU Surplus Store and local 2nd-hand stores.
  2. When using voltages above 5V, be very careful to not apply them to ICs like PICs or other 5V digital devices ... they will be damaged.
  3. Make sure you know the current requirements for all components in your project and make sure your power supplies can provide enough.
  4. Make sure your power supply can handle more current than what you think you need.
  5. Avoid high-current situations as much as possible to reduce cost, increase safety, and prevent EMI problems.
  6. Try to use 5V power supplies for all components if possible to limit the chances of applying high voltage to sensitive components by mistake.
  7. Use a computer power supply to provided voltages to your project. You can find them cheaply, and they provide stable voltages with ample current. Make sure the PS_on wire is grounded for proper operation. Newer computer power supplies require a constant load (e.g., with an added load resistor) to keep them from powering down.
  8. If you use a voltage regulator, be aware that if the voltage is lowered a lot and the current is large, the regulator will generate a lot of heat and you will definitely need a heat sink. An alternative is to use a dc-dc converter that is more efficient. Another alternative is to use a different power supply that is better matched to the load.
  9. Use a small-amperage fuse on your power supply to limit possible damage caused by shorts.
  10. Keep low-current stuff (e.g., microcontroller circuits) separate and isolated (on separate boards) from high-current stuff (e.g., actuators), and use separate power supplies for each.
  11. Be sure to include capacitors across the outputs of batteries and any other sources that don't have capacitors built in.
  12. Turn current off to stepper motors and solenoids when not needed. They can get hot, and they can take current away from other stuff that might need it.
  13. A car battery is a good source for large current.