https://github.com/tiryoh/avr-sample
Simple Sample Program of AVR
https://github.com/tiryoh/avr-sample
Last synced: about 1 year ago
JSON representation
Simple Sample Program of AVR
- Host: GitHub
- URL: https://github.com/tiryoh/avr-sample
- Owner: Tiryoh
- License: mit
- Created: 2014-01-24T14:48:13.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2017-02-22T19:34:56.000Z (over 9 years ago)
- Last Synced: 2024-05-02T01:59:00.685Z (about 2 years ago)
- Language: C
- Homepage:
- Size: 6.84 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# AVR-Sample
## What's this?
Sample Program for AVR.
* ATtiny2313
* ATtiny13A
* ATmega168
* ATmega328P
* etc...
## LISENCE
This repository is released under the MIT License, see [LICENSE](./LICENSE.md).
***
Sample.c
```
#include
int main(void){
/***** IN *****/
DDRD = 0x00; //すべてに"0"を入れてるので"入力"指定。
PORTD = 0xFF; //"1"を入れると内部プルアップ。
/***** OUT *****/
DDRB = 0xFF; //すべてに"1"を入れてるので"出力"指定。
PINB = 0x00; //"1"を入れると出力が反転。
//出力レジスタは"PORT"
//入力レジスタは"PIN"
PORTB = 0x00; //初期化
while(1){
if( PIND == 0x04 ){ //*0000100
PORTB = 0x03 ; //00000011
}
if( PIND == 0x0C ){ //*0001100
PORTB = 0x02 ; //00000010
}
if( PIND == 0x1C ){ //*0011100
PORTB = 0x01 ; //00000001
}
if( PIND == 0x3C ){ //*0111100
PORTB = 0x00 ; //00000000
}
}
return 0;
}
```