What is the simplest way to change the state of a pin. For example is there something like digitalWrite(pin, CHANGE)? I know I can do some if statements to check and see what the previous state was but I'm working with an ATTiny25 and space is critical so I'd like to avoid loops and if statements if thats possible.
Space permitting (it's only one byte), you could keep track with a variable for the state and just do
boolean state = false; ... state = !state; digitalWrite(pin, state);
The chip can do this inherently, see section 11.2.2 of the data sheet. If there is no Arduino function to do this it shouldn't be too hard for a C programmer (which I am not) to write some code to do it.
it shouldn't be too hard for a C programmer
Hmm. Yeah. Define "simplest"...
I'm working with an ATTiny25
Some AVRs (including the tiny25, but NOT atmega8) will toggle an output bit if you write a 1 to the appropriate bit in the PINx register. If you're already using direct port writes, this would be the way to go.