Microcontroller – ATmega2560 |
아래의 Arduino Mega 2560 R3의 핀맵이다.
먼저, 내컴퓨터 > 속성 > 장치관리자 로 들어가서 확인
PC는 COM port8에 설정되어있다.
COM port 확인
Arduino 프로그램은 구조는
void setup(){ //처음 한번만 실행되는 코드이다 //보통 Serial setting 이나 //초기값 setting을 작성한다. } void loop(){ //C언어의 for문과 같다. //실제 돌리고자 하는 코드를 넣는다. }
Arduino Mega2560 보드에 있는 LED를 사용하자.
Blink 실행 코드
// the setup function runs once when you press reset or power the board void setup() { // initialize digital pin 13 as an output. pinMode(13, OUTPUT); } // the loop function runs over and over again forever void loop() { digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(13, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second }