Beginner help!


Closed Thread
Results 1 to 15 of 15

Thread: Beginner help!

Hybrid View

  1. #1
    Join Date
    Apr 2012
    Posts
    6


    Did you find this post helpful? Yes | No

    Default Re: Beginner help!

    Would this code send -5v to the switches alternating or is there some other way to do it?

  2. #2
    Join Date
    Sep 2010
    Location
    Las Vegas, NV
    Posts
    305


    Did you find this post helpful? Yes | No

    Default Re: Beginner help!

    Ahhhh, in a word no the code won't work and the schematic doesn't depict a working circuit.

    If I read it correctly, the schematic has gpio.2 hooked up to a switch that will pull the pin high when the switch closes. If by -5V you mean ground then that won't work. The second switch, hooked up to ground and +5V, will either burn out the switch or shut down your power supply, whichever is weaker.

    Your code doesn't take into account switch position. You'll need to use an IF/THEN or CASE SELECT or something like that. You really need to read the PBP manual, page 6, as there is working code to flash an LED. Except for the part about PORTB should be GPIO.x where x is the port where the LED is connected. There is also info in the book on how to hook up LEDs and switches. It's for a bigger PIC but you can see how is should be done.

    Why don't you focus on getting an LED to light then move on to switches? Read the manual and start with a simple program then you can add to it.

  3. #3
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,172


    Did you find this post helpful? Yes | No

    Default Re: Beginner help!

    Im on cell phone so I can't type details.

    Use IF statement to check if input pins are 1 or 0, then turn on output as desired.


    Check manual, must have example.

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