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 / Enabling or Disabling a pin in c language for 8051

Enabling or Disabling a pin in c language for 8051

|

Microcontroller › 8051 › Enabling or Disabling a pin in c language for 8051

  • This topic has 3 replies, 2 voices, and was last updated 12 years, 2 months ago by AJISH ALFRED.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • November 22, 2013 at 11:53 am #2728
    rainn
    Participant

    I am currently making a very simple vending machine project which uses the 8051 microcontoller.
    the pins im using is

    sbit C=P3^3; ////// “C” is for coffee///////
    sbit T=P3^4; ////// “T” is for tea///////
    sbit H=P3^5; ////// “H” is for hot///////
    sbit D=P3^6; ////// “D” is for cold///////
    sbit S=P3^7; ////// “S” is for purchasing/////

    i have done the coding for lcd initialization and selection.. the problem now is that i need the program to run in sequence for example

    sequence one:
    customer should be able to choose only “C” or “T”..
    (during this sequence all the other pins should be disabled.. any input will be ignored)

    sequence two:
    customer should be able to choose only “H” or “D”..

    sequence three:
    once the above sequence is completed only then customer can press the purchasing push button..

    The question is how can i disable the other pins at respective sequences.. my code for the selection part is below.

     

    void main ()
    {
    TMOD=0x02;
    TH0=0xA4;
    IE=0x00;
    L1= L2= 0;
    a = 0;
    lcd_ini();
    delay(20);
    lcd_command(0x01);
    lcd_string("Select Drink");
    delay(200);
    lcd_command(0x01);
    lcd_string("1.Coffee 2.Tea");
    delay(20);
    flagset=0;
    TR1 = 0;


    while (1)
    {
    if (C==0)
    {
    delay(30);
    lcd_command(0x01);
    lcd_string("Coffee: Hot/Cold");
    }


    if (T==0)
    {
    delay(30);
    lcd_command(0x01);
    lcd_string("Tea: Hot/Cold");
    }

    if (H==0)
    {
    delay(30);
    lcd_command(0x01);
    lcd_string("Hot Selected");
    }


    if (D==0)
    {
    delay(30);
    lcd_command(0x01);
    lcd_string("Cold Selected");
    }

    if (S==0)
    {
    lcd_command(0x01);
    lcd_command(0x80);
    lcd_string("Processing");
    delay(100);
    lcd_command(0x01);
    lcd_command(0x80);
    lcd_string("Please wait");
    L1 = 1;
    delay(100);
    L1 = 0; ///////L1 and L2 is for lights///////
    L2 = 1;
    lcd_command(0x01);
    lcd_command(0x80);
    lcd_string("Remove drink");
    delay(100);
    L2 = 0;
    lcd_command(0x01);
    lcd_command(0x85);
    lcd_string("Thankyou");
    delay (500);


    }
    }
    }

    Thank you in advance :-)

    November 22, 2013 at 1:03 pm #10637
    AJISH ALFRED
    Participant

    Hi,

    Is there any statements in the code in which you are reading the input pins?

    November 22, 2013 at 2:47 pm #10648
    rainn
    Participant

    can i email to u my code??

     

    November 25, 2013 at 5:28 am #10652
    AJISH ALFRED
    Participant

    Please post it here. The idea is, others who have the same doubt may find our discussion helpful.

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

RSS Recent Posts

  • Do i need a buffer? February 7, 2026
  • FM Radio circuits February 7, 2026
  • wall transformer polarity February 7, 2026
  • To buy or DIY? February 7, 2026
  • engineering analysis of shmidth trigger without simulation February 6, 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