pic microcontroller discussion list <> wrote on Wednesday, July 30, 2003 5:38 PM: > Var=0b00000101; That's an option too, but a switch statement is more flexible. > This will blink 2 times wait time will be little longer > By shifting right and reading bit 0 LSB whatever bit 0 is You can probably even do it faster using the fact that the rightmost bit is shifted into carry. Not sure how to tell a compiler, in pic assembler it would be something like rrf Pattern,f ; Move the next bit onto Carry bcf LedShadow,LedPin ; Start with the shadow pin off btfsc STATUS,C bsf LedShadow,LedPin ; Turn it on if the bit was a 1 Actually, it's probably no faster than the way you are proposing. However, if all the other bits in LedShadow are irrelevant, you can do rrf Pattern,f ; Move the next bit into Carry rlf LedShadow,f ; Move the bit onto LedShadow And if you want to maintain the other bits in LedShadow, you can use rrf LedShadow,f ; Lose the previous bottom bit rrf Pattern,f ; Move the next bit into Carry rlf LedShadow,f ; Move the bit onto LedShadow > Then we can use 16 bit or 32 bit variable. I will show you Later. True, and that would also be quite fast, only one more rotate needed per 8 bits. > Thanks for code adjustment No problem (and don't forget to add the ';' which I missed at the end of the line!). I thought about it again while walking my dog this morning, and if code size is an issue, the following would probably compile marginally smaller! >> case (4): timer1test=0x00; break; >> case (5): timer1test=0x00; break; >> case (6): timer1test=0x00; /* NO BREAK, FALL THROUGH TO DEFAULT !!! */ default:led_count=0; break; >> } >> } Nigel -- Nigel Orr, Design Engineer nigel@axoninstruments.co.uk Axon Instruments Ltd., Wardes Road,Inverurie,Aberdeenshire,UK,AB51 3TT Tel:+44 1467 622332 Fax:+44 1467 625235 http://www.axoninstruments.co.uk -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads