Created
March 19, 2016 12:40
-
-
Save pilinux/4d3ee2622f31c7f5af09 to your computer and use it in GitHub Desktop.
Sample usage of PINx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* lab7.c | |
* | |
* Author : mahir | |
*/ | |
#include <avr/io.h> | |
int main(void) | |
{ | |
uint8_t x; // x is an 8-bit unsigned integer | |
DDRB = 0xff; // Set all Port B pins as outputs | |
PORTD = 0xff; // By default, all Port D pins are set as inputs. So here we just activated the pull-ups | |
x = PIND; // We read the input values of D-pins and save them to x | |
while(1){ | |
if (x == 0xff) | |
PORTB = 0b00000001; | |
else | |
PORTB = 0x00; | |
} | |
return 1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment