Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define __AVR_ATmega644P__
- #include <avr/io.h>
- uint8_t getPortA4() {
- return (PINA & 0b00010000) >> 4;
- }
- uint8_t getPortB54() {
- return (PINB & 0b00110000) >> 4;
- }
- void init() {
- //DDR -> Data Direction Register
- DDRA = 0b11110111;
- DDRB = 0b11110011;
- DDRC = 0b11111111;
- DDRD = 0b00000000;
- }
- int main(void) {
- init();
- while(1) {
- if(getPortA4() == 0) {
- if(getPortB54() == 0b00) {
- PORTC = 0x00;
- } else if(getPortB54() == 0b01) {
- PORTC = PIND;
- } else if(getPortB54() == 0b10) {
- // 0101 0001
- uint8_t links = PIND << 4; // 0001 0000
- uint8_t rechts = PIND >> 4; // 0000 0101
- PORTC = links | rechts;
- } else if(getPortB54() == 0b11) {
- PORTC = 0xFF;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement