Date: Thu, 5 Jun 1997 10:07:27 +0800 (GMT) From: Orlando Andico To: Jono cc: djgpp AT delorie DOT com Subject: Re: Parallel port program help In-Reply-To: <01bc672f$b73bba80$b40000c8@Ppro> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk On 23 May 1997, Jono wrote: > I'm trying to write a program that will use the parallel port pins to turn > appliances on and off. I have found the following code, but can't get it > to compile under djgpp. It's supposed to turn pin 2 on at 10:05 for one > minute. If anyone can help, how do I tell it which pins to turn on? > > #include > #include > #include > > int main(void) > { > struct time t; > unsigned port = 0x378; > while() > { > gettime(&t); > if(t.ti_hour==10 && t.ti_min==05) outportb (port,1); > else outportb (port,0); ^ > } > } > > Thanks, > Jono > That part there with the caret. If you outportb (port,1) you toggle PB0 on the parallel port. If you outportb (port,2) it's PB1, etc. You have to look up the pinouts of the parallel port though. And a cautionary note (if you're using home-brew equipment). Do place an optoisolator between each bit of your parallel port and whatever equipment you're running (relays?) so you don't fry your computer if you do something really bad.. ----------------------------------------------------------------------- Orlando Alcantara Andico WWW: http://www2.mozcom.com/~orly/ Email: orly AT mozcom DOT com ICBM: 14 deg. 30' N, 120 deg. 59' E POTS: (+632) 932-2385