Skip to the content
2 layers100.5 × 80 mmPWM motor speed controller, the printed circuit board in 3D

A PWM-based DC motor speed control system built with the ATmega32 microcontroller. The system uses Timer0 (OC0/PB3) to generate a PWM signal that drives a DC motor through an N-channel MOSFET, with push-button speed…

Size
100.5 × 80 mm
Copper layers
2
Thickness
1 mm
Parts
19
Nets
44
Pads
85
Tracks, vias
117, 0
Routed
Yes
KiCad
KiCad 10.0 (file 20260206)
Created
1 Jul 2026
Updated
1 Jul 2026

Overview

PWM motor speed controller is an open-source printed circuit board by daviddavid4real, from the daviddavid4real/ATmega32_PWM_DC_Motor_Control-main repository on GitHub. It is a 2-layer board of 100.5 × 80 mm with 19 parts on 44 nets, routed with 117 tracks and 0 vias.

It is built around the ATMEGA32A-PU. Its parts include 5 resistors, 4 diodes, 4 switches, 2 capacitors and 1 IC. It belongs with the robots and motor control boards and the AVR (ATmega, ATtiny) boards of this library.

Main components

1

README

README.md

ATmega32 PWM DC Motor Control

A PWM-based DC motor speed control system built with the ATmega32 microcontroller. The system uses Timer0 (OC0/PB3) to generate a PWM signal that drives a DC motor through an N-channel MOSFET, with push-button speed control and LED speed-level indicators.

Project Overview

This project demonstrates pulse-width modulation (PWM) as a method of controlling the average power delivered to a DC motor. Instead of simply switching the motor ON/OFF, the ATmega32 generates a variable-duty-cycle square wave that adjusts motor speed smoothly across five discrete levels (0%, 25%, 50%, 75%, 100%).

ControlFunction
Increase button (PA0)Raises PWM duty cycle by one level
Decrease button (PA1)Lowers PWM duty cycle by one level
Stop button (PA2)Immediately sets duty cycle to 0%
LEDs (PB0–PB2)Indicate current speed level
PWM output (PB3 / OC0)Drives the motor via MOSFET switching

System Block Diagram

text
[Push Buttons] --> [ATmega32: Timer0 PWM] --> [Gate Resistor] --> [MOSFET] --> [DC Motor]
                            |                                          |
                       [LED Indicators]                          [Flyback Diode]

Hardware Summary

ComponentDesignatorPurpose
ATmega32-PU1Main controller and PWM generator
DC MotorM1Controlled actuator
N-Channel MOSFETQ1Motor driver (low-side switch)
1N4007 DiodeD4Flyback / back-EMF protection
Push buttonsSW1–SW4Increase, decrease, stop, reset
LEDsD1–D3Speed-level indication
8 MHz CrystalY1External clock source
220 ohm resistorR2MOSFET gate current limiting
330 ohm resistorsR3–R5LED current limiting
10 kohm resistorR1Reset pull-up

Full pin assignments are documented in documentation/pin_mapping_table.md.

How PWM Speed Control Works

The ATmega32's Timer0 is configured in Fast PWM mode, outputting on PB3 (OC0). The duty cycle is controlled by the OCR0 register:

text
D ≈ (OCR0 / 255) x 100%

Pressing the increase or decrease button changes OCR0 in steps, moving the motor between five predefined speed levels. Full calculations are in documentation/duty_cycle_calculation.md, and the timer/register configuration is explained in documentation/pwm_configuration.md.

Repository Structure

text
ATmega32_PWM_DC_Motor_Control/
│
├── README.md
│
├── firmware/
│   ├── src/            # Firmware source code (.c)
│   ├── include/        # Header files (.h)
│   └── hex/            # Compiled .hex output
│
├── kicad/
│   ├── schematic/      # KiCad schematic files
│   ├── pcb/            # KiCad PCB layout files
│   └── gerber/         # Generated Gerber fabrication files
│
├── simulide/
│   ├── circuit/        # SimulIDE circuit file (.sim1)
│   └── screenshots/    # Simulation screenshots
│
├── documentation/
│   ├── block_diagram.png
│   ├── flowchart.png
│   ├── pwm_configuration.md
│   ├── duty_cycle_calculation.md
│   ├── pin_mapping_table.md

Tools Used

ToolPurpose
KiCadSchematic design and PCB layout
MPLAB for VS CodeFirmware development (C)
SimulIDECircuit simulation and PWM verification
Git / GitHubVersion control and submission

Firmware Behavior

text
main()
{
    initialize_gpio();
    initialize_pwm();
    while(1)
    {
        read_buttons();
        update_duty_cycle();
        update_speed_indicators();
    }
}

Source code is available in firmware/src/, and the compiled .hex file used for both hardware programming and SimulIDE simulation is in firmware/hex/.

Simulation

The circuit was simulated in SimulIDE before PCB fabrication to verify PWM generation, button response, LED indication, and motor behavior. An oscilloscope probe on PB3 confirmed the PWM waveform changed correctly across all five speed levels. Full results are documented in documentation/test_results.md.

Status

StageStatus
Schematic design (KiCad)Complete
PCB layout (KiCad)Complete
DRC / ERC checksComplete
Firmware (PWM, buttons, LEDs)Complete
SimulIDE simulationComplete
Gerber file generationComplete
DocumentationComplete

Extension (Optional)

A suggested next step for this project is closed-loop speed control using a rotary encoder, where the ATmega32 measures actual motor speed from encoder pulses and adjusts the PWM duty cycle automatically to maintain a target speed.

Author

Student project for ATmega32 PWM-based DC Motor Speed Control assignment.

ATmega32_PWM_DC_Motor_Control-main

Parts

19
QtyValueFootprintReferences
4SW_PushButton_Switch_THT:SW_PUSH_6mmSW1, SW2, SW3, SW4
3330Resistor_THT:R_Axial_DIN0204_L3.6mm_D1.6mm_P7.62mm_HorizontalR3, R4, R5
3LEDLED_THT:LED_D5.0mmD1, D2, D3
222pFCapacitor_THT:C_Disc_D3.0mm_W1.6mm_P2.50mmC1, C2
110kResistor_THT:R_Axial_DIN0204_L3.6mm_D1.6mm_P7.62mm_HorizontalR1
11N4007Diode_THT:D_DO-41_SOD81_P10.16mm_HorizontalD4
1220Resistor_THT:R_Axial_DIN0204_L3.6mm_D1.6mm_P7.62mm_HorizontalR2
1ATmega32A-PPackage_DIP:DIP-40_W15.24mmU1
1Conn_01x02Connector_PinHeader_2.54mm:PinHeader_1x02_P2.54mm_VerticalJ1
1Motor_DCConnector_PinHeader_2.54mm:PinHeader_1x02_P2.54mm_VerticalM1
1Q_NMOS_GDSPackage_TO_SOT_THT:TO-92_InlineQ1

Similar boards

  • 2 layers347.7 × 146.6 mmMysterium pcb, the printed circuit board in 3D

    Mysterium pcb

    coseyfannitutti/mysterium

    TKL keyboard that can be entirely assembled using only through hole components, including usb type-c

    227 parts541GPL-3.0
  • 2 layers344.4 × 130.8 mmSesame, the printed circuit board in 3D

    Sesame

    str-dst/sesame

    Alice type ergo keyboard using only THT parts

    168 parts331
  • 2 layers364.4 × 167.3 mmRedherring, the printed circuit board in 3D

    Redherring

    dcpedit/redherring

    Red Herring Keyboard PCB and case files

    226 parts253CC-BY-4.0
  • 2 layers228 × 114 mmPlanck thk, the printed circuit board in 3D

    Planck thk

    olkb/planck_thk

    Planck Through Hole Kit

    134 parts169GPL-3.0
  • 2 layers371.5 × 145.3 mmBasketweave, the printed circuit board in 3D

    Basketweave

    null-ll/basketweave

    Through-hole Alice-style keyboard with arrow keys and a rotary encoder

    177 parts129GPL-2.0
  • 2 layers439 × 141.6 mmAek2 usb, the printed circuit board in 3D

    Aek2 usb

    str-dst/aek2_usb

    drop-in replacement pcb for the AEK II

    241 parts55
  • 2 layers317.3 × 154.8 mmLCK75, the printed circuit board in 3D

    LCK75

    lyso1/LCK75

    a 75% through-hole keyboard designed by myself with inspiration from the CFTKB Discipline and Yiancar Gingham

    207 parts45
  • 2 layers285.8 × 124.6 mmPunk75, the printed circuit board in 3D

    Punk75

    dsanchezseco/punk75

    Ortholinear keyboard with 75 keys and all components through hole

    194 parts44GPL-3.0

Questions

How big is the PWM motor speed controller PCB?

It measures 100.5 × 80 mm and has 2 copper layers, 1 mm thick.

What parts does the PWM motor speed controller use?

19 parts, built around the ATMEGA32A-PU. The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.

Where can I download the PWM motor speed controller KiCad files?

From the daviddavid4real/ATmega32_PWM_DC_Motor_Control-main repository on GitHub, at the commit this page was made from: the board is kicad/project/PWM_motor_speed_controller.kicad_pcb and its schematic kicad/project/PWM_motor_speed_controller.kicad_sch. PCBKit opens the board in the browser, with nothing to install.

Can I use the PWM motor speed controller design in my own project?

Its repository states no licence, so its author keeps all rights: ask daviddavid4real before reusing the design.