ECEdge

Exam: GATE 2027 exams are on 6, 7, 13, 14, 20 and 21 February 2027. Official GATE 2027 site

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

From a shell command to the LEDecho 1 > /dev/myleduser programSystem callwrite()Your driverfile_operationsGPIO subsystemgpiod_set_valueLEDon the pin
Your driver is the bridge between a file write and a hardware pin.

Parts list

You can buy the listed parts online here:

PartQtyApprox. priceShop
Raspberry Pi 4 (2 GB) with power supply and microSD card1₹5,500Find on Amazon
LED pack, assorted colours1₹60Find on Amazon
Resistor kit, ¼ W, assorted values1₹150Find on Amazon
Breadboard, 830 points1₹90Find on Amazon
Jumper wire set (male-male and male-female)1₹120Find 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

  1. Write and load a hello-world module and read its message with dmesg.
  2. Register a character device and create /dev/myled with a device class.
  3. Implement open, release, read and write in a file_operations struct.
  4. Use the kernel GPIO descriptor API to drive the LED pin when “1” or “0” is written.
  5. Copy data safely between user and kernel space with copy_from_user.
  6. 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

All 49 project ideas