Arduino looping functions outside while loop

388 views Asked by At

I may be missing something obvious here but I am using my Arduino to communicate via the UART. We can't use Arduino library functions so to print messages out I have to create my own write function. I can do that and it works, the problem is once I include my loop structure for the rest of my program the message won't stopped being printed out even though it is not in the loop. Here is my code:

int main()
{
  initializeAll();
  sprintf(message, "Hello World\n");
  myWrite(message);
  while(1){
    //do nothing yet
  }
}
void UART_transmit(unsigned char data){
  /* Wait for empty transmit buffer*/
  while(!(USCRA & BIT5));

  /*Put data in UDR to be transmitted*/
  UDR = data;
}
void myWrite(char* string){
  int i = 0;
  while(string[i] != '\0'){
    UART_transmit(string[i]);
    i++;
  }
}
0

There are 0 answers