Newbie to pic but not electronics


Closed Thread
Results 1 to 19 of 19

Hybrid View

  1. #1
    Join Date
    Jul 2007
    Posts
    67


    Did you find this post helpful? Yes | No

    Default

    Ohh I get it that makes perfect sense

    So all I would have to do is read the input

    but say when I pressed the button I want the RB0 led to flash 4 times and RB1 led to flash 8 times when I press the button once.

    How would that work?

  2. #2
    Join Date
    Feb 2006
    Posts
    20


    Did you find this post helpful? Yes | No

    Default

    Do you mean how would you have the different LEDs flash a different number of times depending on how many times you push the button? This could be accomplished by waiting for the input pin to go high then adding 1 to a pre-defined variable. You would then wait for the input pin to go low before monitoring the input for a high signal. After a pre-defined amount of time waiting for the high signal, the number of button pushes would be stored in the variable that holds the count.

  3. #3
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Techbuilder View Post
    Ohh I get it that makes perfect sense

    So all I would have to do is read the input

    but say when I pressed the button I want the RB0 led to flash 4 times and RB1 led to flash 8 times when I press the button once.

    How would that work?
    For/Next.....If/Then.....counters in a loop....thousand different ways of doing it.
    Write some code, we'll dig thru it all...

  4. #4
    Join Date
    Feb 2005
    Location
    Kolkata-India
    Posts
    563


    Did you find this post helpful? Yes | No

    Default Try this

    Hi,

    While PicBasic makes your life real easy I still recommend to study the internals of the PIC micro to get the most out of PBP. To get started try the link here http://techtrain.microchip.com/x14/ and view or download the flash based presentation. IMO it accelerates learning the PIC....
    Regards

    Sougata

  5. #5
    Join Date
    Jul 2007
    Posts
    67


    Did you find this post helpful? Yes | No

    Default

    Thank you very much everyone has been helpful

    Although I was reading on the button command wouldn't that be the easiest way to go?

  6. #6
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Techbuilder View Post
    Although I was reading on the button command wouldn't that be the easiest way to go?
    Not if you're just reading a single switch on a single port performing a single function...
    Now if you're looking for functionality like auto-repeat, debouncing, sure, button may be the way to go.

  7. #7
    Join Date
    Jul 2007
    Posts
    67


    Did you find this post helpful? Yes | No

    Default

    Gotcha I guess I will just go with IF, THEN , GO Statements
    How exactly would that work

    I know I would have to set LED to HIGH

    but is this kind of how it would look

    IF port.0=1 THEN
    port.1 = high

    Something like that?

  8. #8
    Join Date
    Jul 2007
    Posts
    67


    Did you find this post helpful? Yes | No

    Default

    Here's a better constructed code I made then the one up

    Button var PORTB.0 ' Push button
    LED1 var PORTB.1 ' Led 1
    LED2 var PORB.2 ' Led 2
    Pushed var byte ' Variable will contain the byte
    If PUSHED =1 Then ' If button is push
    High LED1 ' Turn on the LED
    IF PUSHED=0 Then
    High LED2

    Endif
    Last edited by Techbuilder; - 12th July 2007 at 23:44.

Similar Threads

  1. pic to pic ir link versus wired link : help please anyone
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 30th May 2008, 21:01
  2. Replies: 14
    Last Post: - 26th September 2007, 05:41
  3. PIC to PC newbie
    By Michael in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 19th June 2007, 01:07
  4. PIC Newbie
    By azmax100 in forum Schematics
    Replies: 7
    Last Post: - 23rd February 2007, 04:52
  5. Serial Pic to Pic using HSER
    By Chadhammer in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 11th March 2005, 23:14

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts