vilfred
Member level 1
I am using pic18f,uart,led in my program(xc8 compiler). Here i wish to introduce a control to on off led, for that i use a sequence of hex value
02 03 01 - led on
02 03 02 - led off
if i type 02(ctrl+b-keyboard entry) 03(ctrl+c) 01(ctrl+a) in virtual terminal i need the return value of again 02 03 01 to on my led - this is my concept.
I thought this can be achieved in embedded c program by storing this sequence of values in array. My question is how can i compare the sequence of values in receive register?.
if i receive 02 03 01 value then i transmit the same and made led on, but during simulation in proteus if i press ctrl+a i.e. 02 hex value itself led begin to on and return some garbage value. I feel sorry if iam not clear.
02 03 01 - led on
02 03 02 - led off
if i type 02(ctrl+b-keyboard entry) 03(ctrl+c) 01(ctrl+a) in virtual terminal i need the return value of again 02 03 01 to on my led - this is my concept.
I thought this can be achieved in embedded c program by storing this sequence of values in array. My question is how can i compare the sequence of values in receive register?.
if i receive 02 03 01 value then i transmit the same and made led on, but during simulation in proteus if i press ctrl+a i.e. 02 hex value itself led begin to on and return some garbage value. I feel sorry if iam not clear.
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 int dc[5] = {0x02,0x03,0x01};//storing sequence in dc[5] array dc[5] = UART_rx(); // assigning received value as dc[5] if (dc[0] == 0x02 && dc[1] == 0x03 && dc[2] == 0x01) { TRISB = 0x00; //port pin direction as ouput PORTB = 0x01; // led on in portb 0th pin UART_send(dc[5]); // returning the transmitted value UART_tx(10); // length of trasnmit value }
Last edited by a moderator: