so using a simple if else statement on the code Pommie wrote i can use it to at least do some test runs and have something to present
(the code insert wouldn't work)
C:
main ()
{
ANSEL=0b000000;
ADCON0bits.ADON=0;
TRISA=0b00010000;
TRISC=0b00000000;
T1CON=0b00000000;
while(1){
unsigned int Timer1Count;
TMR1=0; //clear timer
while(!RA4); //wait for high
T1CONbits.TMR1ON=1; //start timer
while(RA4); //wait low
T1CONbits.TMR1ON=0; //stop timer
Timer1Count=TMR1; //copy timer
// use the timer value here to light LEDs etc.
if(Timer1Count<=220){
PORTC=0;
}
else if(Timer1Count >= 220){
PORTC=0b00000001;}
}
}
ADC has 1024 resolution.... 1024 / 15 = 68bit steps.... I think so... ( actually need 16 steps, unless 0 is recognised as 0...)
The trouble here though is he'll need a R-2R setup and switches that are double pole..
To test for your values can be done with maths. Assume 25 either side of the actual value.
So, subtract 175 and divide by 50 should give you the LED pattern.
Code:
while(1){
unsigned int Timer1Count;
unsigned char LED;
TMR1=0; //clear timer
while(!RA4){ //wait for high
T1CONbits.TMR1ON=1;}//start timer
while(RA4){ //wait low
T1CONbits.TMR1ON=0; //stop timer
Timer1Count=TMR1; } //copy timer
// use the timer value here to light LEDs etc.
Timer1Count-=175;
LED = Timer1Count/50;
PORTC=LED;
}
Edit, do you have a scope to check the transmitter is outputting the correct pulses?