Linux character driver for an LED on Raspberry Pi
Write a Linux kernel module that creates /dev/myled, so any program can turn an LED on or off by writing 1 or 0 to a file.
What this proves to recruiters
- You can write kernel code, a rare skill for freshers.
- You understand user space and kernel space.
- You can build and load modules safely.
Skills you will use
- Linux kernel modules
- Character drivers
- GPIO
- C
Parts list
You can buy the listed parts online here:
| Part | Qty | Approx. price | Shop |
|---|---|---|---|
| Raspberry Pi 4 (2 GB) with power supply and microSD card | 1 | ₹5,500 | Find on Amazon |
| LED pack, assorted colours | 1 | ₹60 | Find on Amazon |
| Resistor kit, ¼ W, assorted values | 1 | ₹150 | Find on Amazon |
| Breadboard, 830 points | 1 | ₹90 | Find on Amazon |
| Jumper wire set (male-male and male-female) | 1 | ₹120 | Find on Amazon |
| Total, about | ₹5,900 | ||
Prices are rough online prices in India and change with the seller. You may already have some parts, or find them in your college lab.
As an Amazon Associate I earn from qualifying purchases. Buying through these links costs you nothing extra and helps keep this site free.
Free software
- Raspberry Pi OS with kernel headers
- “Linux Device Drivers, 3rd edition” (free online)
- Bootlin’s free training slides
Steps
- Write and load a hello-world module and read its message with dmesg.
- Register a character device and create /dev/myled with a device class.
- Implement open, release, read and write in a file_operations struct.
- Use the kernel GPIO descriptor API to drive the LED pin when “1” or “0” is written.
- Copy data safely between user and kernel space with copy_from_user.
- Test from the shell (echo 1 > /dev/myled) and from a small C program.
Make it stand out
- Describe the LED in a device-tree overlay instead of hard-coding the pin.
- Add an ioctl to set a blink rate.
Put it on your resume
Wrote a Linux character device driver on Raspberry Pi exposing a GPIO LED as /dev/myled using the GPIO descriptor API.
Replace each [x] with a number you measured. Real numbers make a line believable.
Keep going
This project fits stage 4, “Embedded Linux and connected devices”, of the Embedded systems and firmware roadmap. See also how freshers get into embedded C developer jobs.
More Embedded systems and firmware projects
- Wi-Fi thermometer with an OLED displayBeginner1 weekend~₹1,050
- Bare-metal I²C driver on STM32Intermediate2–3 weekends~₹1,900
- FreeRTOS data logger with SD card and web viewIntermediate2–3 weekends~₹1,050
- Smart plant watering with a phone dashboardBeginner1–2 weekends~₹900
- Line-following robot with PID controlIntermediate2–3 weekends~₹1,850