Quote Originally Posted by lerameur
I think my problem might be the sending code. I have added the output line to my lcd tosee what is sending, it says it is sending V
and I's..

-----------------because a V is ASCII code $56? and the 'I' must be a special character or something-doesn't matter
---------------------

here is the sending code

define osc 20
Include "modedefs.bas"

------------------get rid of this unless you are really using a bootloader
Define LOADER_USED 1
-----------------------------------------------------------

DEFINE LCD_DREG PORTB ' Set LCD Data port
DEFINE LCD_DBIT 4 ' Set starting Data bit (0 or 4) if 4-bit bus
DEFINE LCD_RSREG PORTB ' Set LCD Register Select port
DEFINE LCD_RSBIT 1 ' Set LCD Register Select bit
DEFINE LCD_EREG PORTB ' Set LCD Enable port
DEFINE LCD_EBIT 0 ' Set LCD Enable bit
DEFINE LCD_BITS 4 ' Set LCD bus size (4 or 8 bits)
DEFINE LCD_LINES 2 ' Set number of lines on LCD

CMCON=7 ' Disable comparators
ANSEL=0 ' Set port as digital I/O
ADCON1=7
TrisA = %11111111 'sets all port a as input
TrisB = %00000000 ' sets all port b as output

X VAR BYTE 'VARIABLE TO PUT POT VALUE
B1 VAR BYTE
PORTB = 0 'ALL OUTPUTS LOW
'23

Start:
Pot PortA.2,49,X ' would like PortA.2,175,B0 use number to suit you
Lcdout $fe, 1 'Clear screen
Lcdout $FE,$80,"Pot: ", #X 'Display the numerical value

------------------------------should be 'HEX B1' at the end
LCDOUT $FE,$C0,"Output: ",B1
-------------------------------
Pause 10

IF X <= 60 THEN LED1
IF (X > 60) AND (X <= 120) THEN LED2
IF (X > 120) AND (X <= 180) THEN LED1
IF X > 180 THEN LED2
goto Start

LED1
serout portb.2,n2400, [ $AA, $AA,$AA,$AA,$AA,$AA ]
B1=$AA
goto Start

LED2
serout portb.2, n2400, [ $56,$56,$56,$56,$56 ]
B1=$56
goto Start

LED3
serout portb.2,n2400, [ $55,$55,$55,$55,$55 ]
B1=$55
goto Start

LED4
serout portb.2,n2400, [ $65,$65,$65,$65,$65,$65 ]
B1=$65
goto Start

end



Does your X value change with the POT when you rotate it?
How about this...let's break it down...again. Apparently there is too much going on here that can break the system and you're having trouble figuring out what's going on.....again...............

1. Get rid of the transmitter................

2. Get rid of the receiver...................

3. Get rid of the POT.......................

4. Put a button where the pot was....

5. Make sure the button works...in other words, you push it and an LED connected to the same PIC on a different pin lights up on software command, not because you pushed it and made an electrical connection, then you release it and the LED goes out on software command, not because you removed an electrical connection. Then change the program around to extinguish the LED when the button is pushed, and light the LED when the button is released. That will tell you that you know how to make an LED light up on command. (or something comes up on the LCD that verifies that you are pushing and releasing the button).

6. Then connect the other receiver PIC to the transmitter PIC through the serial port.

7. Set up a program in the receiver to receive control data from the transmitter PIC and act on it in some fashion, and make it repeatable. For example, each press of the button on the transmitter PIC sends a command to light up a different light in the receiver PIC (4 LEDs light up, one after the other, and so on down the line, until the end is reached, then they extinguish and the process starts again.

8. Then, after that is all working, connect the POT back into the transmitter PIC and rewrite your code to display the POT value on the LCD. When that works fine, continue...and not until it works as you want it to.

9. When steps 1-8 all work fine, each and every time, then disconnect the PIC' serial ports and reinsert the transmitter and receiver modules (not the encoder and decoder modules).

10. Add the code back into the transmitter that send out the various control codes for each LED at the receiver PIC. And don't forget about the receiver training code. It's the transmitter that does the training of the receiver, not the receiver itself.

Tune in tomorrow for more...I'm tired of explaining this...
JDG

, connect the 2 PICs at the serial ports.