Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

8051 Input

Status
Not open for further replies.
i think the program should be some thing like this....
#include<stdio.h>
#include<reg51.h>
void delay(int);
sbit inp_pin=P1^0;
void main()
{
P0=P1=P2=P3=0x00;
for(;
{
if(inp_pin==0)
{
P2=0x01; // assuming that u have connected the LED to pin no.21 of 8051;
delay(500);
}
if(inp_pin==1)
{
P2=0x00;
delay(500);
}
}
}
 
anilmudulakar said:
if(inp_pin==0)
{
P2=0x01; // assuming that u have connected the LED to pin no.21 of 8051;
delay(500);
}
if(inp_pin==1)
{
P2=0x00;
delay(500);
}
Please allow me to repeat myself:
mcs51mc said:
Why testing for 1 AND 0 on an input pin??
If it's not a 1 it has to be 0 or what else do you expect?? 0.5
Ever heard of the ELSE statement guys??
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top