This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP430g2553 to turn button on and off by writing single click and double click on the putty.

Other Parts Discussed in Thread: MSP430G2553

Hi, I am new to MSP430G2553 Launchpad development. I want to write a code that turns button on and off by writing "double click " and  "single click" commands on putty.

Most  of the codes I have found on the forum are about tuning the LEDs on and off....I could not fine anything to start with for the buttons.

Would you please provide me some clues?

Thank you in advance for your cooperation. 

  • kidist zegeye said:
     I am new to MSP430G2553 Launchpad development

    Your question suggests that you're not just new to the MSP - Are you familiar with any other microcontrollers? Are you familiar with any form of programming?

    kidist zegeye said:
    I want to write a code that turns button on and off

    What 'button' ?

    kidist zegeye said:
    writing "double click " and  "single click" commands on putty

    By "putty", I assume you mean the terminal emulator program?

    So, what this actually means is that you will send strings of characters out of the PC's COM port.

    Therefore, this part of your program must involve receiving strings of characters at the UART...

    kidist zegeye said:
    ....I could not fine anything to start with for the buttons

    A button is just a switch - so it doesn't make any sense for the microcontroller to be turning it on or off !!

    kidist zegeye said:
    Would you please provide me some clues?

    I think you need to provide some better clues as to what you're actually trying to do!

    http://www.catb.org/esr/faqs/smart-questions.html#goal

  • sorry for not stating my problem clearly. what I mean is that I am now able to turn the leds on and off by writing commands on my putty(using UART by sending strings ).

    I just want now to be able to turn the switch on and off by using commands(not manually ) and switching on and off the swicthes I can turn the leds on and off.

    what I explicitly mean is  instead of turning the button on /off  manully to turn off /on the leds or to do some other task I want to be able to turn on and off the switch(push button  on P1.3 of my microcontroller) using commands on my terminal. LIke If I write "double click" it should function in the same way as I double click the pushbutton( to switch manually).I hope what I want to say is clear this time.

    Thank you in advance for your cooperation.

  • kidist zegeye said:
    ).I hope what I want to say is clear this time.

    No, it is still very muddled!

    You keep talking about turning switches and buttons on and off - which makes no sense!

    kidist zegeye said:
    If I write "double click" it should function in the same way as I double click the pushbutton( to switch manually).

    OK, that bit makes sense.

    But, if you want to turn an LED on, wouldn't make more sense to have the command as, "LED ON"?!

    And, to turn it off, "LED OFF"?

    As you've said, you already have examples of how to turn the LEDs on & off.

    So the remaining parts of your homework are:

    1. Receive the strings on the UART;
    2. Interpret the strings.

    Having interpreted the strings, you then apply the appropriate code to turn the LED on or off...

     

  • Thanks for your fast reply.I am now able to turn on /off  the leds.

    //#define LED_RED BIT0
    //#define LED_RED_ON (P1OUT |= BIT0)
    //#define LED_RED_OFF (P1OUT &=!BIT0)
    //#define LED_RED_TOGGLE (P1OUT ^= BIT0)


    #define LED_GREEN BIT6
    #define LED_GREEN_ON (P1OUT |= BIT6)
    #define LED_GREEN_OFF (P1OUT &= !BIT6)
    #define LED_GREEN_TOGGLE (P1OUT ^= BIT6)

    Now I am done with the LEDs.

    My question is mainly concerned with closing and opening the switch( because that is what we do by manually pressing the push button connected to p1.3 on/off ).Now my aim is to do this manual operation by writing a command from terminal.

    Is it possible to  close and open the switch (  connected to P1.3 of my msp430g2553) by the following operation 

    #define LED_button BIT3
    #define LED_button_ON (P1OUT |= BIT3)
    #define LED_button_OFF (P1OUT &=!BIT3)

    will this operation cause the switch to be on and off(I have to see it physically  turn on and off by commanding it from the putty terminal).Besides, I want to measure the amount of milliseconds the button is pressed(the switch is closed)  before being released. After  solving this questions it will not be difficult to write the strings using UART.Thankyou so much for your help.

  • kidist zegeye said:
    Is it possible to  close and open the switch (  connected to P1.3 of my msp430g2553) by the following operation 

    No - of course not!

    Think about it: a switch is a mechanical device which is operated by physical force!

    What you need to do is to use your serial commands as your trigger to switch the LEDs instead of the switch.

     

  • It is not about  the leds as i have already done that. How can I   close and open the switch which is a mechanical device (on/off the push button connected to pin 1.3)  by setting this particular port pin 1.3 in the output direction and using command  instead of using physical force? I just want to turn on and off the hardware(switch) using commands(I used to do that by pushing the push button on/off).I also want to order  by command the mechanical device(switch) to be pressed on and measure the amount of time it remains pressed.This way I can see the push button being on and off by command only with no physical force.I am so sorry for all the confusion I created.I thank you in advance for helping to me.

  • kidist zegeye said:
    I just want to turn on and off the hardware(switch) using commands

    Andy Neil gave you complete description how to do it:

    Andy Neil said:
    1. Receive the strings on the UART;
    2. Interpret the strings.

    Having interpreted the strings, you then apply the appropriate code to turn the LED on or off...

    What exactly you did not understand?

    kidist zegeye said:
    How can I   close and open the switch which is a mechanical device

    Well you cannot press mechanical button using software. It's impossible. Without actuator. Better upon receiving command just to light LED on instead of trying to press button that lights LED on.

  • Now you have answered  my question.I thought that it is possible to press the switch just like the way I turn on the led. Now I know it is impossible.

    Thank you very much.

  • kidist zegeye said:
    Now you have answered  my question.I thought that it is possible to press the switch just like the way I turn on the led. Now I know it is impossible.

    You'd need an electric magnet or a motor to do so.

    However, if you'd be more clear abotu the purpose, meybe there's a solution.

    Usually, a pushbutton or switch is an input device. If you press it, the controller can 'see' it and act accordingly. Dependign on model, pthe pushbutton opems or closes an electrical connection while pressed (a switch swill switch between the two states but remain in its current state when you stop operating it, whiel a pushbutton retuerns to initial state if you release it)

    usually, the controller or an external resistor is pulling the input line of the controller to VCC while the button shorts it to GND, so when you press the button, the input changes from high to low. Which can be detected and handled.

    Now if the pushbutton is also input to a different device, you can simulate a button press by the controller by just switching the former input to an output and pulling the line to GND as if the buitton was pressed. (however, if the button is pressed, the controller cannot 'undo ' it by forcefully pulling it high).
    This way, you're not operating the button, but simulating a pressed button. The attached external device won't see a difference.

**Attention** This is a public forum