EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise
You are here: Home / Topics / a very basic program not working?

a very basic program not working?

|

Microcontroller › 8051 › a very basic program not working?

  • This topic has 1 reply, 2 voices, and was last updated 13 years, 7 months ago by AJISH ALFRED.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • September 14, 2012 at 5:01 pm #1952
    Eli
    Participant

    # include<reg51.h>
    sbit a=P1^1;
    sbit b=P1^2;
    sbit p=P1^3;
    sbit q=P1^4;
    sbit r=P1^5;
    sbit mot1p=P2^0;
    sbit mot1n=P2^1;
    sbit mot2p=P2^2;
    sbit mot2n=P2^3;
    void main()
    {

    P1=0xFF;
    while(1)
    {
    if((p&q&r==1) && (a&b==0))
    {
    mot1p=1;
    mot1n=0;
    mot2p=1;
    mot2n=0;
    }
    }
    }

    guyz this is simple program ive written where in i connect five switches from p1.1 to p1.5 with logic 00111 but when i check the o/p at p2.0 to p2.3 it gives all logic 1s after each reset when it should have been 1010 acc to the program.im using keil ide and at89s52 as muc
    please people i need your help
    thanks in advance

     
    September 16, 2012 at 6:27 pm #8589
    AJISH ALFRED
    Participant

    Hi,

    I understand that you’ve connected switches on port 1. Then why are you trying to write into the same port  as ‘ P1=0xFF ‘, those pin should be made input and you are supposed to read those pins.

  • Author
    Posts
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Log In

RSS Recent Posts

  • AI algorithm for bots April 17, 2026
  • SDCC Array Access In Timer 0 Interrupt Handler April 16, 2026
  • EasyEda program has a major bug April 16, 2026
  • ANOTHER OLD PROJECT REDO April 16, 2026
  • How to set the OSCAL in a PIC 12F675 April 16, 2026

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2026 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise