This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Read and Write

Hi

Since I want to set three input and one output so

my code would be like that:

//Configurations
sbit READ_1=P1^0;
sbit READ_2=P1^1;
sbit READ_3=P1^2;
sbit SEND=P1^3;

READ_1=1; //INPUT
READ_2=1; //INPUT
READ_3=1; //INPUT
SEND=0; //OUTPUT

//Main program

bit x1,x2,x3;


x1=READ_1;
x2=READ_2;
x3=READ_3;

SEND=x1;

Is it correct?

Arron

Parents
  • 
    #include <Reg52.H>
    sbit output = P1^0;
    sbit input = P1^1;
    /* .........................................................
    void main (void)
    {
    bit x;
    // Set switch pin for reading
    input = 1;
    while(1)
    {
    x = input; // Read Pin 1.0
    output = x; // Write to Pin 1.1
    }
    }
    
    

    Is my code right to set input and output as reading and writing respectively?

Reply
  • 
    #include <Reg52.H>
    sbit output = P1^0;
    sbit input = P1^1;
    /* .........................................................
    void main (void)
    {
    bit x;
    // Set switch pin for reading
    input = 1;
    while(1)
    {
    x = input; // Read Pin 1.0
    output = x; // Write to Pin 1.1
    }
    }
    
    

    Is my code right to set input and output as reading and writing respectively?

Children