Society of Robots - Robot Forum

Software => Software => Topic started by: An3 on March 19, 2010, 03:42:34 AM

Title: How to turn off a port on Axon
Post by: An3 on March 19, 2010, 03:42:34 AM
Hi. From the Axon source code there was a code to turn on/off a LED on the Axon.
Code: [Select]
void LED_off(void)
{PORT_ON(PORTB,6);}
I was wondering if it was possible to turn a different port on/off? ??? I've connected a basic status LED circuit directly to an I/O port, and i would like to be able to turn it on/off in the program. Thanx for all replies :)
Title: Re: How to turn off a port on Axon
Post by: SmAsH on March 19, 2010, 05:14:01 AM
Yup, just change the "PORTB, 6" to the port letter and number you want to control.
So, instead it could be "PORTB, 3" or something similar.
Title: Re: How to turn off a port on Axon
Post by: An3 on March 21, 2010, 05:30:47 AM
Hmm. I think there's some sort of problems with the code then. I've tried running the axon_test.c program witch turns on/off all ports and still  the LED wont turn off... I'm also having problems changing the reference voltage to the ADC to 2.56V. I think i make a new post on how to troubleshoot my code  :-\ Anyway, thanx for the reply man  :)
Title: Re: How to turn off a port on Axon
Post by: Webbot on March 21, 2010, 08:25:38 AM
The Axon libraries tend to make most IO pins into output pins. So if your LED is like this
--------- +5v
      |
    ___
    \   /
    ----
      |
     R
      |
    I/O Pin

Then you will need to make sure the pin is made into an input by changing the Data Direction Register (DDR) for the Port and Pin you are connecting to. You light the LED by making the input pin go low.

Whereas if your LED is like this
 
    I/O Pin
      |
    ___
    \   /
    ----
      |
     R
      |
    Ground

The port need to be an output port and you light the LED by setting the pin high

  
Title: Re: How to turn off a port on Axon
Post by: Admin on March 22, 2010, 05:20:45 AM
Search the source code example page for how to configure a port.

As Webbot said, it'll need to be configured as an output first.

Also, which port are you trying to use?
Title: Re: How to turn off a port on Axon
Post by: An3 on April 08, 2010, 04:29:02 AM
Thanx for all replies  :) When i saw Webbot's illustration i noticed what i had done wrong. I had connected the three-pin connector from the LED to Axon the wrong way. The result was that the LED wasn't connected to the I/O-pin on Axon at all, only between ground and source  ::)