Gast
#1753328
Hi ich habe hier mal einen Auszug aus einem Programm, das ich gefunden habe. Ich habe jetzt noch zum Testen zusätzlich PB0 aus PORTB als Eingang hinzugefügt und den Pull-Up Widerstand aktiviert. Stimmt das so? Habs wie bei den anderen auch gemacht. So nun möchte ich diesen in das uint8_t buttons aufnehmen. Wie mache ich das? Weil wenn ichs einfach so hinzufüge meckert Win AVR immer, das das nicht gültig wäre oder so. Wäre super wen mir jemand helfen könnte! Hier noch der entsprechende Code Ausschnitt: /* * Initialize the hardware to read the button states. * * Set the ports to input with pullups enabled. */ void buttons_init(void) { DDRD &= ~(_BV(PD0) | _BV(PD1) | _BV(PD2) | _BV(PD3) | _BV(PD4) | _BV(PD5) | _BV(PD6)); PORTD = _BV(PD0) | _BV(PD1) | _BV(PD2) | _BV(PD3) | _BV(PD4) | _BV(PD5) | _BV(PD6); DDRB &= ~(_BV(PB0)); PORTB = _BV(PB0); } /* * Callback function from the rc5 module. This reads in the current button * state and returns the corresponding rc5 command code. */ uint8_t rc5_get_cmd(rc5_cmd_t *cmd) { uint8_t buttons = (~PIND) & (_BV(PD0) | _BV(PD1) | _BV(PD3) | _BV(PD4) | _BV(PD5) | _BV(PD6)); *cmd = 0xff; BTW wie poste ich denn so Codeausschnitte richtig?