| Code: |
|
int main(void) { int lights = 0; int note = 1; DDRA = 0xFF; // port A is output DDRB &= 0x00; // port B is input USART_Init(); // initialize usart while (1) { if (PINB & 0x01) // button is up { PORTA = 0; } else { PORTA = 0xFF; MIDI_Send(1, note%128); MIDI_Send(0, note%128); note++; } } } |
So, this is part of the code I received to put into my hardware (using an ATMEL ATMEGA32) to create music, but I do not have much experience in C. I am trying to understand this code at the moment and will learn the C syntax and structure at another time.
What does a "&=" mean?
I would assume that 0x01 is a hexidecimal that is evaluated to be 1, which I believe is the value True if it is used as a Boolean value. Why PINB & 0x01? Evaluating this with Boolean Algebra, wouldn't that be the same as PINB?
