Hi Gilles, > You are right Ashley, we have to make a C Block around the Else. > I have surrounded the needed command with the { } and > everything is working > well now. Good to hear its working! > >This means that every time through the loop, the > output_low(PIN_A3); is > >being executed so there would be a very brief pulse at the > output of A3, not > >the intended long pulse. > > Hum here i dont follow you Ashley. I understand the C block around the > Else, but why a brief pulse at the output of A3 if > output_low(PIN_A3); is > skipped, not executed ? > Other thing, When a 1 is find, output_high(PIN_B1); and > output_high(PIN_A3); are both executed and A3 have to be high > for the delay > time. and the output_low(PIN_A3); is never executed, but the > output stayed > low as observed with a LED ? Sorry, I guess I didn't explain that too well.. In your original code, the output_low(PIN_A3) isn't skipped. It is always executed each time though the loop. This is because it was outside the "if/else" statement. So if you come to a "1" in your string, the if condition is true so both B1 and A3 are set high, then the next statement will be the output_low(PIN_A3) because it is the next statement after the full if/else block. This means that the PIC will set its output High, then almost immediately Low again. Essentially this is way too fast for you to see with an LED. If you put an oscilloscope on the output pin you would probably see the pulse. --- Ashley Roll Digital Nemesis Pty Ltd www.digitalnemesis.com Mobile: +61 (0)417 705 718 > > >void main() { > > > > > > char string [28] = "11101110100011101110100000" ; > > > int i,j; > > > > > > set_tris_a (0); > > > set_tris_b (0); > > > > > > setup_wdt(WDT_72MS); > > > setup_counters(RTCC_INTERNAL,RTCC_DIV_2); > > > setup_timer_1(T1_DISABLED); > > > setup_timer_2(T2_DISABLED,0,1); > > > setup_vref(FALSE); > > > setup_comparator(FALSE); > > > > > > while(1) > > > { > > > for (i=0;i<26;++i) > > > { > > > If (string[i] == '1') > > > { > > > output_high(PIN_B1); > > > output_high(PIN_A3); > > > } > > > Else > > > output_low(PIN_B1); > > > output_low(PIN_A3); > > > //delay_ms(333); > > > for (j=0;j<185 ;++j) > > > { > > > restart_wdt(); > > > delay_ms(16); > > > set_tris_a (0); > > > set_tris_b (0); > > > } > > > } > > > } > > > } -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu