Jump to content

rickson

Members
  • Content count

    1
  • Joined

  • Last visited

Community Reputation

0 Neutral

About rickson

  • Rank
    Newbrie
  1. HI, I'm currently using a microcontroller 16f877A. The Tx and Rx pins of my microcontroller will output either 1 or 0 respectively. The microcontroller is connected to my laptop using RS232-USB converter. The microcontroller has been programmed and the connection was tested. May i know what is the code to determine the output for Tx and Rx using VB? Because what i would like to do for my project is when the Tx output is 1, then some operation will be running and same for the Rx... Below is roughly what my microcontroller will do: #if pin no 19 & 20 at PIC is 0, then will make pin no 25 & 26 as 0 (output), so it wont activate your visual basic #if pin no 19 at PIC is 1, then will make pin no 25 as 1 (output)so, activate visual basic due to first sensor #if pin no 20 at PIC is 1, then will make pin no 26 as 1 (output) so activate visual basic due to second sensor So, may i know whether my microcontroller code is correct as below? void main() { trisd=1; // set port d as input trisc=0; // set port c as output portd=1; // initialize port d as 0 portc=1; // initialize port c as 0 while(1) { if (portd== 0b00000000) // if pin no 19 & 20 at PIC is 0, then will { // make pin no 15 & 16 as 0 (output) portc=0x00; // so it wont activate your visual basic } if (portd== 0b00000001) // if pin no 19 at PIC is 1, then will { // make pin no 25 as 1 (your output) portc.f6=1; // activate visual basic due to first sensor } if (portd== 0b00000010) // if pin no 20 at PIC is 1, then will { // make pin no 26 as 1 (your output) portc.f7=1; // activate visual basic due to second sensor } if (portd== 0b00000011) // if pin no 19 & 20 at PIC is 1, then will { // make pin no 15 & 16 as 1 (your output) portc=0b00000011; // activate visual basic due to both sensors } } } Thanks.
×