Beginner help!


Closed Thread
Results 1 to 15 of 15

Thread: Beginner help!

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default Re: Beginner help!

    When you post code, use the Advanced options, you can use the Code icon (looks like #) to post so it looks like this:

    Code:
    TRISB = %00001000
    
    SIG1 = GPIO.3
    OUTPUT1 = GPIO.1
    OUTPUT2 = GPIO.2
    
    LOOP:
    
    OUTPUT1 = SIG1
    OUTPUT2= 0
    PAUSE 200
    
    OUTPUT1 = 0
    OUTPUT2 = SIG1
    PAUSE 200
    
    GOTO LOOP
    You can name variables any name you want, as long as you don't use reserved names (check the manual for naming conventions and reserved names).

    Spacing is irrelevant as long as you don't break up words.

    Comments are optional, but they will help you remember what you are doing, and others go through your code.

    If you post in WYSIWYG format, your code gets messed up, ie: you lose leading % on bits. Hover your mouse over the big A icon, you want to be in Source mode.

    I don't understand the part about alternating a negative ground signal. As explained, your best bet would be to post a schematic of the components you are using and how you plan to wire them up.

    Robert

  2. #2
    Join Date
    Apr 2012
    Posts
    6


    Did you find this post helpful? Yes | No

    Default Re: Beginner help!

    Code:
    Trisio = %001000
    
    ground var gpio.3
    pin1 var gpio.1
    pin2 var gpio.2
    
    loop:
    
    Pin1 = ground
    pin2 = 0
    pause 200
    
    pin1 = 0
    pin2 = ground
    pause 200
    
    goto loop
    Name:  Untitled.jpg
Views: 914
Size:  58.0 KBThe switches trigger buttons on a remote control. Thanks for all the help by the way ive really learned alot.
    Last edited by Recognize; - 25th April 2012 at 19:24.

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

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

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