Ogu Reginald
Full Member level 6
- Joined
- Oct 7, 2011
- Messages
- 369
- Helped
- 47
- Reputation
- 94
- Reaction score
- 46
- Trophy points
- 1,308
- Location
- Nigeria
- Activity points
- 3,391
Hi everyone, below is a portion of my code on how I defined the input of AT89S52 microcontroller. Also attached is the circuit diagram. My questions are:
1. Is it necessary add a resistor between the input of the microcontroller and the ground in other to make the input of the microcontroller be well defined at all times.
2. Must I always write a logic one in the code in other to configure the pins as input.
3. The way I defined the pins in the main program, is it alright.
Please if there needs to be adjustment anywhere let me know, thank you
Here is the code:
#include<reg51.h>
sbit low=P1^0;
sbit high=P1^1;
sbit danger=P1^2;
sbit emergency=P1^3;
void delay(int delay_time) // Time delay function
{
int j,k;
for(j=0;j<=delay_time;j++)
for(k=0;k<=1000;k++);
}
void main(void)
{
low=high=danger=emergency=1;
}
1. Is it necessary add a resistor between the input of the microcontroller and the ground in other to make the input of the microcontroller be well defined at all times.
2. Must I always write a logic one in the code in other to configure the pins as input.
3. The way I defined the pins in the main program, is it alright.
Please if there needs to be adjustment anywhere let me know, thank you
Here is the code:
#include<reg51.h>
sbit low=P1^0;
sbit high=P1^1;
sbit danger=P1^2;
sbit emergency=P1^3;
void delay(int delay_time) // Time delay function
{
int j,k;
for(j=0;j<=delay_time;j++)
for(k=0;k<=1000;k++);
}
void main(void)
{
low=high=danger=emergency=1;
}