maintain push button...

Discussion about projects that used PIC Microcontroller, Hardware Interface, Programming Algorithm and etc......

maintain push button...

Postby syntium87 » Fri May 13, 2011 10:38 am

i have this problem..how to program a push button...when being pressed it become an input (maintain)..then press again to release it become an output..(release)..how to write it in c code ??help me on this code... :(
syntium87
Novice
 
Posts: 27
Joined: Sun Apr 03, 2011 12:51 am

Re: maintain push button...

Postby shahrul » Fri May 13, 2011 5:40 pm

What output hardware on the same pin with that push button?
The pin that become input and output maybe in 1 wire serial example I2C or some other protocol. If that only push button, what for to do that?
User avatar
shahrul
Professional
 
Posts: 812
Joined: Sat May 16, 2009 9:54 pm
Location: Selangor

Re: maintain push button...

Postby yonghui » Fri May 13, 2011 6:37 pm

hi,

why u need to do thing like this?
why dont just use one pin as the push button input and another as output? things get easy with that.



regards,
yh
thanks&regards,
yh
yonghui
Professional
 
Posts: 732
Joined: Mon Sep 28, 2009 3:27 pm

Re: maintain push button...

Postby syntium87 » Fri May 13, 2011 7:05 pm

the switch that i used its a maintained push button...the pic i used to interfaced with lcd dsply..when being pressed,it maintain..an output with some display shown..when pressed again..output with dffrnt display shown..

help me on this coding.... :(
syntium87
Novice
 
Posts: 27
Joined: Sun Apr 03, 2011 12:51 am

Re: maintain push button...

Postby shiyan » Fri May 13, 2011 8:35 pm

Please explain clearly, you are confusing us, I am sure not only me, other also confuse on what you want. It doesn't make sense what you want to do. If yourself are not clear on what you want to do, how can other help?

Seem that you are going to interface LCD + switch with PIC microcontroller. The question is, why need use same pin for that purpose? Why can't use 1 pin for switch and other pin for LCD? You can still have different message on LCD with the switch.

Programming? Look at the same code from Cytron's DIY, there are plenty of project uses LCD with switches. Even their SK40C have sample of that.
User avatar
shiyan
Amateur
 
Posts: 189
Joined: Wed Jun 09, 2010 10:59 am

Re: maintain push button...

Postby syntium87 » Fri May 13, 2011 8:50 pm

wait2..sory for any misunderstand matters..

i type the msg be4 in hurry...actually is like this..

PIC interface with LCD and a maintained push button..of coz i seperate the pin for lcd n the push button..i connect the lcd to PORTD of pic16f877a...and for the push button..i connect to a pin from PORTB..

my quest about the program is what the c code i need to write when the operation like this...--->

--> push button pressed for 1st time(to maintained position)...it display on the LCD with some msg..then
-->when the push button pressed again (to released position)...it display some different msg on the lcd..


help me on the coding plz.. :?
syntium87
Novice
 
Posts: 27
Joined: Sun Apr 03, 2011 12:51 am

Re: maintain push button...

Postby robosang » Fri May 13, 2011 11:18 pm

I have to agreed with shiyan.... you are confusing all of us. Now the question is no more related to input and output on 1 pin. Is about programming.

And what you requested is the very basic of using push button or any digital input, LCD is just an output which can display message. Write some program first, then we can give comments. As suggested by shiyan, you can actually refer to Cytron DIY projects.

You want someone to write program for you? Go ahead and wait. :o
robosang
Expert
 
Posts: 1239
Joined: Wed Jun 10, 2009 5:37 pm

Re: maintain push button...

Postby shahrul » Sat May 14, 2011 12:44 am

syntium87 WROTE:wait2..sory for any misunderstand matters..

i type the msg be4 in hurry...actually is like this..

PIC interface with LCD and a maintained push button..of coz i seperate the pin for lcd n the push button..i connect the lcd to PORTD of pic16f877a...and for the push button..i connect to a pin from PORTB..

my quest about the program is what the c code i need to write when the operation like this...--->

--> push button pressed for 1st time(to maintained position)...it display on the LCD with some msg..then
-->when the push button pressed again (to released position)...it display some different msg on the lcd..


help me on the coding plz.. :?

owh, so this is easy. You ask the hard way.
The way to do is put 1 variable name ex message.
Then, write code
If push button pressed, change the message value. When push button pressed again, change the message value again. You may use message++, but depends on no of message you need.
The LCD part, use the message value to display different message.
You can refer Lesson Set Phone Number and Lesson Set Time and Date to managing push button and LCD.
User avatar
shahrul
Professional
 
Posts: 812
Joined: Sat May 16, 2009 9:54 pm
Location: Selangor

Re: maintain push button...

Postby yonghui » Sat May 14, 2011 6:08 pm

i am confused with what is maintaine switch? is tat a push on push off switch ?

if yest its simple, the push button can give 1 or 0 value depending on the state of the switch.

if (sw==0)
printLCD("msg 1");
else
printLCD("msg 2);
thanks&regards,
yh
yonghui
Professional
 
Posts: 732
Joined: Mon Sep 28, 2009 3:27 pm


Return to PIC Microcontroller

Who is online

Users browsing this forum: No registered users and 6 guests