Thanks Tyler, That did the trick . I googled it after I sent off the message and made the second {} brackets but didn't have the "else" statement. You cleared it for me. Thanks you so much for the quick response.
Csaba On Apr 2, 2009, at 12:21 AM, Tyler Littlefield wrote: > >// ELSE ???? // Here I would need a "ELSE" h1--; but how ? > if (bla) > { > do something > } > else > { > do something else > } > > Thanks, > Tyler Littlefield > Web: tysdomain.com > email: ty...@tysdomain.com > My programs don't have bugs, they're called randomly added features. > > ----- Original Message ----- > From: Csaba Zvekan > To: c-prog@yahoogroups.com > Sent: Wednesday, April 01, 2009 3:53 PM > Subject: [c-prog] Quadrature Rotary Encoder read > > Hi guys, > > Newbi here . I am trying to read a quadrature rotary encoder and > porting some BASIC code over to C. I got it to decrement properly . > But incrementing doesn't seem to work in my little example. > The original code I had was running on a dsPIC30F6014 now I am trying > the same thing on a LP2103 ARM7. Same rotary encoder though. > It seems it never gets to my increment part . > OK my question is more like how would I structure/do a "ELSE" command > in C .Coming from basic I sometimes need that. > Do I state a second if command with the "~" sign ? > > Here is my little sub routine in C: > > static void encoderRead(void) > { > if (IOPIN &(1<<RENC1A)){ // true if button released (active low) > if (IOPIN & (1<<RENC1B)){ // true if button released (active low) > h1++; > // ELSE ???? // Here I would need a "ELSE" h1--; but how ? > h1--; > } > > while ((IOPIN & (1<<RENC1A)) | (IOPIN & (1<<RENC1B))) > { > > } > } > > } > > any help greatly appreciated. > > Csaba > > [Non-text portions of this message have been removed] > > [Non-text portions of this message have been removed] [Non-text portions of this message have been removed]