hello, I just got an Axon and am messing with it trying a few things being i dont have much programing experiance.
The problem is with the delay function during the button press. the sensor readings display fine in terminal untill i hit the button then the program seems to freeze. Why is this? even if i just set up a program to count and display the numbers in terminal it does the same thing unless i use a for loop instead of delay_ms(1000).
#include "SoR_Utils.h"
int main(void)
{
configure_ports();
uartInit(); // initialize the UART (serial port)
uartSetBaudRate(1, 115200); //set UARTD speed, for USB
//initialize analog to digital converter
a2dInit();
//configure ADC scaling
a2dSetPrescaler(ADC_PRESCALE_DIV32);
//configure ADC reference voltage
a2dSetReference(ADC_REFERENCE_AVCC);
rprintfInit(uart1SendByte);//USB
rprintf(" Hello, I'm working!");
LED_on();
while(1)
{
if(button_pressed())
{
servo(PORTC,0,700);// move the servo
delay_ms(20);
}
int se0;//variable to hold the data of the sensor
se0=a2dConvert8bit(0);//get the data and store it in se0
rprintf("%d\n",se0);//send the data to terminal
}
return 0;
//End main
}