Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[PIC] sending a string by pushing a button

Status
Not open for further replies.

Emiel

Newbie level 1
Newbie level 1
Joined
Aug 10, 2015
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
11
Hello , forum members. I have a pic 16F628A and I am using this with a bleu tooth module. I want to expand the program that I have with the next future : if I press a pushbutton the pic has to send a command ( SET CONTROL AUTOCALL 1000 6000 RFCOMM) or something like this. I am not very good in programming so I hope someone can help me with a few lines of code. The uart is already active because it is used already. I hope that you can help me with this small problem. Thanks a lot. Regards Emil
 

If you have a working program then presumably you already have the routines needed to send characters to the Bluetooth module via the UART. All you need to do is to pass the starting address of a character string (presumably null terminated if that is the 'end of string' marker your function uses - look at how the program already sends strings via the UART).
To detect a button press, you need to decide which pin the button will be connected to, presumably with a pull-up or pull-down resistor - that is part of your design. The key thing to remember with physical buttons and switches is that they do not open and close cleanly and therefore you need to take into account "contact bounce". There are a lot of code examples for many different types of processor and many different languages on the Internet to do the "debounce" in code. You will need to look at what resources you have available on yourr device that you can use but often a timer is used to regularly check the button state.
Once you have debounced the button input, then you can select how you will detect the button press. Often this is done by testing a flag in the main loop of your program and, when the flag is set, to sent the string to the UART and clear the flag.
Have a go for yourself as that is the best way to learn. Make sure that you have a good development environment with a debugger so that you can develop your code, program the device and then verify how the program is working with the debugger.
If/When you have some code examples and questions about why it may not be working as you expect, then we can help you with those.
Susan
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top