/*
* 03_external_pulldown.c
*
* Created: 2020-12-17 오후 6:08:40
* Author : User
*/
#define F_CPU 16000000UL
#include <avr/io.h>
#include <util/delay.h>
#define BUTTON1 PORTE0
#define BUTTON2 PORTE2
int main(void)
{
DDRE = 0x00;
DDRB = 0xff;
while (1)
{
if (PINE & (1 << BUTTON1) | PINE & (1<<BUTTON2)){
PORTB = 0b00000001;
}
else {
PORTB = 0b00000000;
}
}
}
/*
* 03_external_pulldown2.c
*
* Created: 2020-12-17 오후 6:35:00
* Author : User
*/
#define F_CPU 16000000UL
#include <avr/io.h>
#include <util/delay.h>
#define BUTTON1 PORTE0
#define BUTTON2 PORTE2
int main(void)
{
DDRE = 0x00;
DDRB = 0xff;
while (1)
{
if (PINE & (1 << BUTTON1) | PINE & (1<<BUTTON2)){
PORTB = 0b00000000;
}
else {
PORTB = 0b00000001;
}
}
}
/*
* 03_external_pullup.c
*
* Created: 2020-12-17 오후 6:55:00
* Author : User
*/
#define F_CPU 16000000UL
#include <avr/io.h>
#include <util/delay.h>
#define BUTTON1 PORTE0
#define BUTTON2 PORTE3
int main(void)
{
DDRE = 0x00;
DDRB = 0xff;
while (1)
{
if (PINE & (1 << BUTTON1) & (PINE & (1 << BUTTON2)))
{
PORTB = 0b00000000;
}
/* else if (PINE & (0 << BUTTON1) | (PINE & (0 << BUTTON2)))
{
PORTB = 0b00000001;
}*/
else {
PORTB = 0b00000001;
}
}
}
'임베디드 > Atmega128' 카테고리의 다른 글
모터 L 298 (0) | 2020.12.23 |
---|---|
atmega128- 03_external_pullup.c , internal_pullup 내부풀업 외부풀업 (0) | 2020.12.22 |
가져온 코드 (0) | 2020.12.15 |
도트매트릭스 8x8 숫자 0~9 띄우기 / 흐르게 하기 (0) | 2020.12.14 |
반도체 다이오드 트랜지스터 (0) | 2020.12.14 |