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

    I have done the blinking led and I own picbasic pro that I got from microengineering labs. My programmer I bought from ebay and I do not remember what errors I got since it has been months since I tried it.

    How do you know rentron didn't just put it on with out trying the firmware out?

    Who knows

    But anyway I don't get how reading the inputs work yet.


    Let's start simple say I wanted two leds to chase eachother

    I connect led 1 to RB0and led 2 to RB1

    and I guess I would connect the switch to RB2

    but would I have to read RB2 Input
    then send and output to RB0 and RB1 when RB2 makes contact?

    The PIC I am using is a 16F84A
    Last edited by Techbuilder; - 6th July 2007 at 21:06.

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Techbuilder View Post
    How do you know rentron didn't just put it on with out trying the firmware out?
    And throw ANY credibility out the window? I don't think so... Besides, I've seen their work, I've used their products and software. Good stuff...

    But anyway I don't get how reading the inputs work yet.
    Let's start simple say I wanted two leds to chase eachother
    I connect led 1 to RB0and led 2 to RB1
    and I guess I would connect the switch to RB2
    but would I have to read RB2 Input
    then send and output to RB0 and RB1 when RB2 makes contact?
    The PIC I am using is a 16F84A
    Good example of how to use a button and the BUTTON command in Section 5.2 of the PBP manual. But that's probably too much for your example...
    To read a pin, you have to set it to an input (as the datasheet states), you may also need a variable to store the state of that pin so you can work with it elsewhere.

    input_pin var portb.2
    input input_pin
    temp var byte
    temp = input_pin

    Now "temp" has the state of PortB.2.
    Again, break it down to the simplest possible level...
    Write a program that reads the portb.2, and have the LED on portb.0 light up if the button on portb.2 is pressed, and the LED on portb.1 light if the button is released.

  3. #3
    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?

  4. #4
    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.

  5. #5
    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...

  6. #6
    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

  7. #7
    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?

  8. #8
    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.

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