Dad 220 Module 7 Project Two: Exact Answer & Steps

9 min read

Ever stared at a half‑finished circuit board and wondered why the “project two” in Module 7 feels like it’s written in another language?
You’re not alone. The dad 220 course is notorious for that one assignment that looks simple on paper but turns into a midnight‑oil‑burning session for most students. Below is the one‑stop guide that walks you through everything you need to know—what the project actually asks for, why it matters, the steps that actually get you a working prototype, the pitfalls that trip up even seasoned tinkerers, and a handful of practical shortcuts that will save you time (and sanity).


What Is the Dad 220 Module 7 Project Two?

In plain English, Project Two is a microcontroller‑driven temperature‑controlled fan system. The assignment asks you to:

  1. Read a temperature sensor (usually an LM35 or TMP36) with the ATmega328P on the dad 220 development board.
  2. Convert that analog voltage into a readable Celsius value.
  3. Use PWM (Pulse‑Width Modulation) to drive a small DC fan so it spins faster as the temperature rises.
  4. Display the current temperature on the on‑board 16×2 LCD.

That’s the gist. The “module 7” part just means you’ve already covered the basics of I/O, ADC, and PWM in earlier labs, so this project is the first real‑world integration test. Think of it as the “hello world” of embedded control—but with a fan that actually moves That's the whole idea..

The Hardware You’ll Touch

  • dad 220 development board – ATmega328P, 5 V regulator, built‑in ISP header.
  • LM35/TMP36 temperature sensor – analog output, 10 mV/°C scaling.
  • N‑MOSFET (e.g., IRL540) – switches the fan’s 12 V supply.
  • DC fan (5 V‑12 V) – the load you’ll modulate.
  • 16×2 character LCD (HD44780 compatible) – shows temperature.
  • Breadboard, jumper wires, 10 kΩ potentiometer (for LCD contrast).

The Software Skeleton

  • Initialize ADC (select channel, set prescaler).
  • Initialize Timer/Counter1 for 8‑bit fast PWM.
  • Initialize LCD (4‑bit mode, clear screen).
  • Main loop: read ADC → convert → map to PWM duty → update fan speed → print temperature.

If you’ve ever built a blinking LED, you already have the building blocks; you just need to stitch them together in the right order The details matter here..


Why It Matters / Why People Care

First, the short version: this project is the gateway to real‑world embedded design. Because of that, it forces you to juggle analog reading, digital output, and human‑machine interface—all in a single loop. That’s the kind of integration that employers look for on a résumé.

Second, the practical side: temperature‑controlled fans are everywhere—from computer cases to 3‑D printer enclosures. Knowing how to implement a reliable control loop means you can adapt the same code for a smart thermostat, cooling system for a Raspberry Pi, or even a DIY greenhouse. The concepts you master here are reusable.

Finally, the grading factor: most instructors weight Module 7 heavily because it demonstrates that you can read a sensor, process data, and drive an actuator—the three pillars of embedded engineering. Nail this, and you’ll cruise through the rest of the course.


How It Works (Step‑by‑Step)

Below is the full walkthrough, from wiring the board to polishing the code. Feel free to skip sections you already know, but I recommend reading the whole thing at least once before you start soldering.

1. Wiring the Temperature Sensor

  1. Power the sensor – Connect VCC to the 5 V rail on the dad 220 board and GND to ground.
  2. Signal line – Hook the sensor’s output pin to ADC0 (PC0) on the ATmega328P.
  3. Decoupling – Place a 0.1 µF ceramic capacitor close to the sensor’s VCC and GND pins to filter noise.

Pro tip: Run a short 10 cm wire; longer leads act like an antenna and introduce jitter in the ADC reading.

2. Setting Up the Fan Driver

The fan runs off a separate 12 V supply, so you need a MOSFET to switch it safely Worth keeping that in mind..

  1. Source → Ground of the 12 V supply.
  2. Drain → Negative lead of the fan.
  3. Positive lead of the fan → +12 V rail.
  4. Gate → Connect to OC1A (PB1) on the ATmega328P through a 220 Ω resistor.
  5. Pull‑down – Add a 10 kΩ resistor from gate to ground to keep the fan off at power‑up.

3. Hooking Up the LCD

The 16×2 LCD uses 4 data lines plus RS, EN, V0 (contrast), VCC, and GND.

LCD Pin dad 220 Pin Purpose
RS PD0 Register select
EN PD1 Enable pulse
D4‑D7 PD2‑PD5 Data bus (4‑bit mode)
V0 Pot wiper Contrast (pot tied to 5 V & GND)
VCC 5 V Power
GND GND Ground

Make sure you set the LCD to 4‑bit mode in software; it frees up pins for other tasks.

4. Initializing the ADC

void ADC_init(void) {
    ADMUX  = (1 << REFS0);            // AVcc reference, ADC0 channel
    ADCSRA = (1 << ADEN)  |           // Enable ADC
             (1 << ADPS2) | (1 << ADPS1); // Prescaler = 64 (125 kHz)
}
  • Why 64? At 16 MHz CPU clock, a prescaler of 64 gives ~125 kHz ADC clock, which is within the recommended 50‑200 kHz window for the ATmega328P.

5. Converting ADC Reading to Temperature

The LM35 outputs 10 mV per °C. With AVcc = 5 V and a 10‑bit ADC (0‑1023), each step equals ~4.88 mV Nothing fancy..

float read_temp(void) {
    ADCSRA |= (1 << ADSC);               // Start conversion
    while (ADCSRA & (1 << ADSC));        // Wait for finish
    uint16_t raw = ADC;                  // 0‑1023
    float voltage = raw * (5.0 / 1023.0); // Convert to volts
    return voltage * 100.0;              // 10 mV/°C → *100
}

6. Setting Up PWM for Fan Speed

We’ll use Timer/Counter1 in 8‑bit fast PWM mode.

void PWM_init(void) {
    TCCR1A = (1 << COM1A1) | (1 << WGM10); // Non‑inverting PWM on OC1A
    TCCR1B = (1 << WGM12) | (1 << CS11);   // Prescaler = 8, start timer
}
  • Duty cycle mapping: 0 °C → 0 % duty, 50 °C → 100 % duty. Clamp the value to avoid over‑driving the fan.
void set_fan_speed(uint8_t duty) {
    OCR1A = duty; // 0‑255
}

7. Updating the LCD

Use a lightweight library like lcd.h (or write your own 4‑bit routine). The key call is:

lcd_gotoxy(0,0);
lcd_printf("Temp: %2.1fC", temperature);

Refresh every 500 ms to keep the display readable without flicker.

8. The Main Loop

Putting it all together:

int main(void) {
    ADC_init();
    PWM_init();
    lcd_init();
    lcd_clear();

    while (1) {
        float temp = read_temp();               // 0‑150 °C range
        uint8_t duty = (temp > 50) ? 255 : (temp / 50.0) * 255;
        set_fan_speed(duty);
        lcd_gotoxy(0,0);
        lcd_printf("Temp: %2.

That’s the core. From here you can add **hysteresis** (to avoid fan chattering) or a **soft‑start** routine if your fan draws a lot of current.

---

## Common Mistakes / What Most People Get Wrong

1. **Forgetting the MOSFET gate resistor.** Directly driving the gate from PB1 works, but the fast edges can cause ringing on the fan’s power line. A 220 Ω resistor tames the spike.

2. **Using the wrong ADC reference.** Many students leave ADMUX at the default (internal 1.1 V). The result is a wildly inaccurate temperature reading. Double‑check `REFS0` is set to AVcc.

3. **Skipping the contrast potentiometer.** The LCD looks like a glorified block of text if V0 isn’t tuned. Turn the pot until the characters are crisp; it’s a small but essential step.

4. **Mapping PWM linearly without a ceiling.** If the ambient temperature hits 80 °C, the duty cycle can exceed 255, wrapping around and stopping the fan. Clamp the duty: `if (duty > 255) duty = 255;`.

5. **Neglecting the fan’s start‑up current.** Small fans can draw 200‑300 mA at start‑up, which briefly dips the 12 V rail. Adding a 0.1 µF decoupling capacitor across the fan’s supply pins smooths the dip.

6. **Hard‑coding delays.** Using `_delay_ms(500)` inside the main loop blocks the MCU from handling other tasks. If you later add a button or serial debug, replace the delay with a timer‑based state machine.

---

## Practical Tips / What Actually Works

- **Calibrate once, forget it.** Measure the sensor’s output at 0 °C (ice water) and at 25 °C (room temp). Adjust the conversion factor in code if you see a consistent offset. It saves you from chasing phantom bugs later.

- **Use the built‑in LED for debugging.** Blink PD7 whenever the fan duty changes by more than 10 %. It’s a quick visual cue that your control loop is active.

- **Breadboard layout matters.** Keep the fan’s 12 V wires away from the analog sensor leads. A tidy layout reduces noise on the ADC channel.

- **Add a software debounce for the temperature reading.** Take three successive ADC samples, discard the highest and lowest, and average the middle one. This simple “median filter” smooths out jitter without extra hardware.

- **Consider a lookup table** if you need a non‑linear fan curve (e.g., slower ramp up until 30 °C, then aggressive). Store the table in PROGMEM to conserve RAM.

- **Power‑up sequence:** Turn on the 5 V regulator first, then the 12 V fan supply. This prevents the MOSFET gate from seeing an undefined voltage at reset.

---

## FAQ

**Q: Can I use a thermistor instead of an LM35?**  
A: Absolutely. A 10 kΩ NTC thermistor works, but you’ll need a voltage divider and a different conversion formula (`R = R0 * (T0/T - 1)`). The ADC code changes, but the PWM part stays the same.

**Q: My fan never spins—what’s the first thing to check?**  
A: Verify the MOSFET gate voltage with a multimeter while the MCU is running. You should see ~5 V when PWM duty > 0. If not, double‑check the PWM pin assignment and that Timer1 is correctly configured.

**Q: The LCD shows garbage characters.**  
A: Usually a contrast issue or a missed initialization command. Turn the potentiometer slowly; if it still looks bad, re‑run the `lcd_init()` sequence and ensure the RS/EN pins aren’t shorted.

**Q: Is it safe to run the fan directly from the 12 V supply without a diode?**  
A: Yes, because the fan is an inductive load but it’s non‑reversing. Adding a flyback diode (e.g., 1N4007) across the fan terminals is a good habit; it protects the MOSFET from voltage spikes when the fan turns off.

**Q: How do I add a temperature alarm (buzzer) at 70 °C?**  
A: Connect a small piezo buzzer to another digital pin (e.g., PD6). In the main loop, after reading temperature, do `if (temp >= 70) PORTD |= (1<
Just Finished

Out the Door

Explore the Theme

If This Caught Your Eye

Thank you for reading about Dad 220 Module 7 Project Two: Exact Answer & Steps. We hope the information has been useful. Feel free to contact us if you have any questions. See you next time — don't forget to bookmark!
⌂ Back to Home