Society of Robots - Robot Forum
Electronics => Electronics => Topic started by: washb0ard on July 16, 2014, 05:31:23 PM
-
Hello all,
I see the below piece of code in the photovore_v1.c.. And based on how the Led is wired up in the pcb. I am confused whether it is supposed to glow when LED_off is called, can someone please explain?
I feel that when LED_on is called a digital is in output on the pin DP4 which is connected to the negative of LED and the positive of LED is connected to 5V(Vcc). Since there is no potential difference iam not sure if it supposed to glow
Code:
configure_ports(); // configure which ports are analog, digital, etc.
a2dInit(); // initialize analog to digital converter (ADC)
a2dSetPrescaler(ADC_PRESCALE_DIV32); // configure ADC scaling
a2dSetReference(ADC_REFERENCE_AVCC); // configure ADC reference voltage
/*********ADD YOUR CODE BELOW THIS LINE **********/
delay_cycles(500);//a small delay to prevent crazy oscillations
LED_off();//turn LED on
-
The reason I am trying to get my led to light up is because i am trying to trobleshoot. I get a WRITE FAILED from pony prog but my robot is doing something(always turning to the right) also Led never lights up.
-
Per the diagram, http://www.societyofrobots.com/images/sbs_avr_schematic.png (http://www.societyofrobots.com/images/sbs_avr_schematic.png) the LED goes between PD4 and VCC, so to turn the LED on you need to set PD4 low.
From the code (SoR_Utils.h):
void LED_on(void)
{
PORT_OFF(PORTD, 4);//turn LED on
}
void LED_off(void)
{
PORT_ON(PORTD, 4);//turn LED off
}
The function LED_on uses PORT_OFF which is:
#define PORT_ON( port_letter, number ) port_letter |= (1<<number)
#define PORT_OFF( port_letter, number ) port_letter &= ~(1<<number)
and results in PORTD pin 4 going low which should turn the LED on.
So, to turn the LED on, you would call LED_on.
I have not used the pony prog so no help on that.