PDA

View Full Version : newbie question



daphne8888
- 21st March 2008, 18:17
hi,
i am new with microcode studio.my problem is i need to connect switches to pic16f877 to "on" the pic so that i can send my data to the lcd.but how to "off" the pic to stop sending data by writing coding in pic?i need the command that can stop the pic from continue sending data when the switch is opened.thankz.

JD123
- 21st March 2008, 18:21
hi,
i am new with microcode studio.my problem is i need to connect switches to pic16f877 to "on" the pic so that i can send my data to the lcd.but how to "off" the pic to stop sending data by writing coding in pic?i need the command that can stop the pic from continue sending data when the switch is opened.thankz.

Hu? Try again. Makes no sense.

daphne8888
- 21st March 2008, 18:42
i mean that i connect a port to a push button where is the other end is connected to a pull up resistor with 5V. when i push the button, it will on. but after i release, it should b off but why my pic on the port still is 'high' ? got what coding that can change the input that "high" to "low"?

skimask
- 21st March 2008, 19:11
i mean that i connect a port to a push button where is the other end is connected to a pull up resistor with 5V. when i push the button, it will on. but after i release, it should b off but why my pic on the port still is 'high' ? got what coding that can change the input that "high" to "low"?
Still doesn't make much sense....losing something in the translation....
But if I'm getting what you're saying, the 'high' to 'low' command is right in the PBP manual.

JD123
- 21st March 2008, 21:08
The diagram says a lot.

The end of the switches that is connected to the resistors should go to ground and the resistors should go to the pin ports.



PIN<--------->SWITCH<---------->GROUND
^
|
|
|
L----------->RESISTOR<-------->Vdd(power)

Port (pin) Logic is HIGH with switch idle, LOW when switch is pushed. This is for the first picture, when (unlike what you said) the resistors are tied to ground, In the second picture I can't see where they are tied.

Anyway I NOW understand what you are saying. What's going on is you push the button for a high, the port goes high, but when you release the switch, the port still reads high. That's called a "FLOATING INPUT" and a poor design. Use the logic I show above. It's a good way to keep the pins from floating (not high, not low, but read as high).

skimask
- 21st March 2008, 21:31
The diagram says a lot........It's a good way to keep the pins from floating (not high, not low, but read as high).
Now the translation makes sense....somewhat.... :)

daphne8888
- 22nd March 2008, 09:38
y the data lines of my lcd from pic doesnt light up? is it due to the programming problem ? or due to the pic ports? because i connect the data lines to port B.4-B.7 of pic.

JD123
- 22nd March 2008, 14:50
I can't make out that part as the pictures don't show those connections in full. Anyway, use pull-up resistors on the data pins going to the LCD or the weak pull-up port option if it's available on those pins. Past that, it maybe a code issue.

Post a clear picture of the pins to LCD connections and post some code.

daphne8888
- 22nd March 2008, 15:48
Thanks JD123.i have my work done half way!but now i have another problem.I'm trying to write a simple password system which can confirm the password that i keyin at the beginning.Do u have any idea?i try to search through internet but cant find the one i really understand with.
i also attach my circuit diagram and some coding.Please tell me if i make any mistake.Thanks again.

JD123
- 22nd March 2008, 16:20
For a password, I'd use logic like this:

(Every key pressed sends "#" so that someone looking over your shoulder can't see what you entered.)

password is a an array that you setup and holds the password value

for i = 0 to 3 'for 4 digit password
read keys
if no key, re-read keys
if key pressed <> password[i] then fail = 1
send LCD "#", no CR of LF
next i

if fail = 0 then go forward, else LCD "FAIL" (or something), clear LCD, fail = 0 and go back to password loop


This only the logic flow, not verbatim code.

daphne8888
- 25th March 2008, 11:35
thanks alot guys..i have made it!!!
i really appreaciate alot..