Fan174
Member level 2
I need help in a program that will read the sensor and send to the port of the computer
Please look at the attached circuit
I wrote this program
How to write program that will read the sensor and send to the port of the computer
Please look at the attached circuit
I wrote this program
Code:
#include<reg51.h>
sbit Sensor = P2^0; // Sensor connected to p2.0
#define High 1
#define Low 0
//Initialize Timer 1 for serial communication
void initialize()
{
TMOD=0x20; //Timer1, mode 2, baud rate 9600 bps
TH1=0XFD; //Baud rate 9600 bps
SCON=0x50;
TR1=1; //Start timer 1
}
// Funtion to transmit serial Data
void transmit()
{
sensor = High;
while(TI==0);
TI=0;
}
void main()
{
while(1)
{
initalize();
transmit();
}