Some issues: 0. What's your name 1. Read:
http://www.justanotherlanguage.org/content/jallib/tutorials/tutorial_adc_intro 2.. Where is 'enable_digital_io()'? 3. It's not clear to which pin your potmeter is connected (pin_A0 or pin_B4)? The comments must match the actual code! 4. Channel numbers start with 0 (like all indexes in Jal) Rob. On 04.09.14 15:11, Picske wrote:
I'm trying to write a program but I treid everything but It doesn't work.. There are no errors but still.. I want to make a program where I use a analog Pin (AN0) whit a potentiometer now if the value of the potentiometer gives me 2,5V or higher a Led should turn on, If i goes under the 2,5V the Led should go out.. Can somebody help me?? Sorry english is not that good :) here is the program I have until now: include 16f877a -- pic 16f877a inladen pragma target clock 20_000_000 -- 20MHZ crystal pragma target OSC HS -- HS crystal or resonator pragma target WDT disabled -- no watchdog pragma target DEBUG disabled -- no debugging pragma target LVP disabled -- no Low Voltage Programming const ADC_CHANNEL_A = 1 -- AN11 (pin_B4) const byte ADC_NCHANNEL = 1 -- max, for use of AN11 and AN13 const byte ADC_NVREF = ADC_NO_EXT_VREF -- no external Vref const word ADC_RSOURCE = 20_000 -- 5K potmeters const bit ADC_HIGH_RESOLUTION = false -- low resolution include adc -- include ADC library adc_init() -- init ADC library pin_A0_direction = input Pin_D0_direction = output pin_D0 = low Var byte measure_a forever loop measure_A = adc_read_low_res(ADC_CHANNEL_A) if measure_A < 128 then pin_D0 = high else pin_D0 = low end if end loop
-- R. Hamerling, Netherlands --- http://www.robh.nl -- You received this message because you are subscribed to the Google Groups "jallib" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/jallib. For more options, visit https://groups.google.com/d/optout.
