Created
May 7, 2020 00:42
-
-
Save dev001hajipro/2f4a17b8a491faf71d2c4a3b4d796cd0 to your computer and use it in GitHub Desktop.
LED点灯
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
/* | |
* GccApplication1.c | |
* | |
* Created: 2020/04/24 19:51:08 | |
* Author : dev001hajipro | |
8-PDIP | |
PB5 1| tiny13 8|VCC | |
A3 PB3 2| |PB2 (SCK A1 | |
A2 PB4 3| |PB1 (MISO | |
GND 4| |PB0 (MOSI | |
*/ | |
//#define F_CPU 128000UL // 128kHz | |
#include <avr/io.h> | |
#include <util/delay.h> | |
int main(void) | |
{ | |
// 初期化 | |
DDRB = 0b00010001; // 0:入力(デフォルト) 1:出力 | |
PORTB = 0b00001000; | |
uint8_t state; | |
while(1) { | |
_delay_ms(10); | |
state = PINB & (1 << PINB3); | |
if (state == 0) | |
{ | |
PORTB |= (1 << PORTB0); | |
} | |
else | |
{ | |
PORTB &= ~(1 << PORTB0); | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment