He should have used a describing name for the input and bit, like ALARM_POR= T = and ALARM_BIT and defined these in a header file to PINB1 and PINB. This way he could have changed the definition for ALARM_PORT and ALARM_BIT = at = one place only if he wanted to use another input pin. The source code would = also directly tell what he wanted to do. I don't know the AVR but I take it that as he wrote it, is a general way to = check for a bit in a port using the predefined names for ports and bits. If = this is the case I got it wrong from the beginning since he not only didn't = provide a way to change the port pin for a specific use in one place but al= so = didn't use an understandable name that easily can be redefined. = /Ruben > Though the code author's not really done anything wrong, since PINB and P= B1 are > both defined in the standard header file provided by Atmel, and are stand= ard > constants. Arguably he should have used PINB1 instead of PB1 for better c= larity. > = > On 3/7/07, Ruben J=F6nsson wrote: > > > > > > > > The thing is PB1 is a constant indicating pin number, and it was > > shifting > > > the 1 PB1 times to the left and then ANDing it to PINB. > > > > > > Just a missreading > > > > > > THANKS!! > > > > > > > Which proves the fact that in order to write maintainable code it is ve= ry > > important to choose a meaningful name for variables and constants. > > > > The original author actually did manage half way since he in fact provi= ded a > > way to easily change both the port and pin for a function in one place = - the > > header file. > > > > I would have used macros, though. > > > > /Ruben > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D > > Ruben J=F6nsson > > AB Liros Electronic > > Box 9124, 200 39 Malm=F6, Sweden > > TEL INT +46 40142078 > > FAX INT +46 40947388 > > ruben@pp.sbbs.se > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D > > > > -- > > http://www.piclist.com PIC/SX FAQ & list archive > > View/change your membership options at > > http://mailman.mit.edu/mailman/listinfo/piclist > > > -- = > http://www.piclist.com PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist > = > = > = > -- = > No virus found in this incoming message. > Checked by AVG Free Edition. > Version: 7.5.446 / Virus Database: 268.18.7/712 - Release Date: 2007-03-0= 6 15:42 > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D Ruben J=F6nsson AB Liros Electronic Box 9124, 200 39 Malm=F6, Sweden TEL INT +46 40142078 FAX INT +46 40947388 ruben@pp.sbbs.se =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D -- = http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist