[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [CPROG] Kommentar til begynderprogram?



Kresten Skovsted Buch wrote:
Hej

Jeg håber der er en på listen der vil kommentere dette lille c-program for
mig. Specielt linie 4 og 9.


Jeg har koblet en række lysdioder til databenene på min parallelport
således at en diode lyser når der åbnes for et af benene på porten.

Når jeg kører programmet lyser en af dioderne. Hvis jeg ændrer linie
9 til outb(0, BASEPORT); så slukker den istedet.


Hvordan kan jeg ændre mit program så jeg kan tænde/slukke en af de andre dioder?

Er der en der lige vil forklare mig det?

!:  #include <stdio.h>
2:  #include <unistd.h>
3:  #include <asm/io.h>
4:  #define BASEPORT 0x378
5:  int main() {
6:    if (ioperm(BASEPORT, 3, 1)) {
7:      perror("ioperm"); exit(1);
8:    }

9: outb(1, BASEPORT);

11:   if (ioperm(BASEPORT, 3, 0)) {
12:     perror("ioperm"); exit(1);
13:   }
14:   exit(0);
15: }

Hvis jeg ikke tager meget fejl, så er første argument til outb en unsigned char eller lignende.
Min man outb siger desværre ikke noget om dette :-(


Du kunne jo så lave et lille lysshow ved blot at lave en løkke om outb og en sleep.

fx. i stil med
for(i = 255; i--;)
{
outb(i, BASEPORT);
sleep(1);
}

Med venlig hilsen
Egon Andersen



 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 20:09 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *