Review your favorite Linux distribution.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 03-19-2004, 06:40 AM   #1
LQ Newbie
Registered: Mar 2004
Location: Makhanlal Chaturvedi University, Bhopal, INDIA
Posts: 11

Rep: Reputation: 0
Unhappy How to write Device Driver to control LED?

If any one can help me in writing device driver, to handle simple works like controlling a seven segment LCD Display or controlling a Stepper motor or controlling an LED from serial port on Linux System.

I have the option to write a device driver to control the switching of an LED through a serial port on Linux system. I would then extend it to support more complex functioning.

The first stage is to design a device driver to send +ve voltage on Serial Port to which an LED is attached.

Then to design an interface over that.

Then to extend the driver to support complex functions.

But all that on Linux.

I can write code in C to send +ve voltage to serial ports, but am not able to convert that to device driver.

Looking for help and generous support.
Old 04-01-2004, 07:33 AM   #2
Registered: Aug 2003
Location: Edinburgh, Scotland
Distribution: Gentoo
Posts: 246

Rep: Reputation: 30
Driver writing is a complex task but the O'Reilly book "Linux Device Drivers" is brilliant. In short a module is normally written in C. You define the functions int init_module(void) and void cleanup_module(void) to handle loading and unloading the module. Other functions can be used to create entries into /dev or /proc, write to I/O ports / memory, etc. Note that debugging kernel code is a fair bit harder than debugging a normal program as incorrect code can potentially hang the kernel and you have no access to the standard C libraries (i.e. many useful functions disappear). The O'Reilly book I mentioned is available to read on the web at and contains a lot more information than I can post.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
write control character q on linux 7.2 suchi_s Linux - Software 1 03-21-2005 04:03 AM
how to write device driver for Irda santu432 Programming 1 07-23-2004 01:29 PM
how to write a device driver raghu mitra Linux - Software 1 07-22-2004 03:26 PM
remote control device driver infamous41md Programming 5 03-09-2004 12:47 PM
how to write a device driver dummyagain Programming 3 10-20-2003 09:36 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:25 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration