I am having issues with the functionality of the available outputs. I am using serial communication so my PD0 and PD1 are being used, leaving me only PC5 to use as an output. I am trying to use the information being received from serial to turn on PC5 at specified times. For some reason, I have been having a lot of difficulties. At first I thought it was a problem with processing the serial, but now I am thinking it may be how I am activating PC5.
Are there any examples of code showing how to control PC5? I want to compare mine with it.
First you have to set the direction of the pin (DDRC)
Then write a 1 or 0 to the pin. You change the values of the register as a whole, so you have to use bitwise operators.
DDRC |= (1<<PORTC5); //Set pin 5 (the 6th) as an output - the data direction register wil be 'OR'ed with 00100000'
PORTC |= (1<<PORTC5); //Turn pin on port register will be 'OR'd with the same value above.
PORTC &= ~(1<<PORTC5); //turn pin off - port register will be 'AND'ed with the inverted form of 00100000, which is 11011111.