Rob, I just tried your code it works fine except there is A miner problem when I slowly turn the pot before it turns on it blinks randomly when I turn the pot little more it stays on ok then same thing happens to all of them I think we need to give a range or so what do you think ? Thank you for your time and effort. Andre -----Original Message----- (sorry about previous 'empty' post) Andre Abelian wrote: What about something like: unsigned char i, tmp; tmp = 0; for (i=0; i > I am working on C code for test using 18f252 > I need to convert ADRESH to bar graph style led movement. > This code works fine on demo board but I think there is > Shorter method any idea will appreciate. > > if (ADRESH==0) > { > PORTB=0b00000000; > } > if ((ADRESH>0)&&(ADRESH<=30)) > { > PORTB|=0b00000001; > } > if ((ADRESH>=31)&&(ADRESH<=61)) > { > PORTB|=0b00000011; > } > if ((ADRESH>=62)&&(ADRESH<=92)) > { > PORTB|=0b00000111; > } > if ((ADRESH>=93)&&(ADRESH<=123)) > { > PORTB=0b00001111; > } > if ((ADRESH>=124)&&(ADRESH<=154)) > { > PORTB|=0b00011111; > } > if ((ADRESH>=155)&&(ADRESH<=185)) > { > PORTB|=0b00111111; > } > if ((ADRESH>=186)&&(ADRESH<=216)) > { > PORTB|=0b01111111; > } > if ((ADRESH>=217)&&(ADRESH<=255)) > { > PORTB|=0b111111111; > } > -- Rob Hamerling, Vianen, NL phone +31-347-322822 homepage: http://www.robh.nl/ -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body