[아두이노] ICSP핀을 이용하여 USB잭 없이 코드 업로드(ICSP 프로그래머 부트로더 굽기)
·
Arduino
EasyEDA라는 툴의 사용법을 공부하여 PCB 제작을 하려고 한다. 최대한 작고 간단하고 깔끔하게 나만의 보드를 만드려고 하는데 이 USB잭이 제법 큰 공간을 차지한다.다른 보드들은 USB잭 없이 프로그램을 업로드 하여 잘만 사용하던데.. 방법을 찾아보았다. ICSP.. 아두이노 보드에 ICSP라는 핀이 있는것만 알고 이때동안 관심을 주지 않았는데 부트로더 업로드를 해주는 역할과 함께 프로그램 코드도 업로드 할 수 있는 핀이라는 것을 알게 되었다.이렇게 되면 PCB 부품 배치에서 USB 관련 소자들을 제거하여 더 깔끔하게 PCB를 만들 수 있을거 같다. 대표적인 방법 중 하나로 ISP 소스코드를 프로그래머 보드로 설정한 보드에 업로드한 뒤, 원하는 소스코드를 프로그래머 보드를 통해 타겟 보드에 업로드 ..
[아두이노] MCP2515를 이용한 자동차 CAN 상태 값 가져오기
·
Arduino
앞으로 자동차 CAN으로 간단하게 만들 것들이 많아질거 같아서 MCP2515를 이용하여 CAN 상태 값을 가져오는 예제를 시험삼아 만들어 보았다. #include #include MCP_CAN CAN0(10); // CS 핀 설정void setup() { Serial.begin(115200); if (CAN0.begin(MCP_ANY, CAN_500KBPS, MCP_8MHZ) == CAN_OK) { Serial.println("CAN 초기화 성공"); } else { Serial.println("CAN 초기화 실패"); } /* // 마스크 및 필터 설정 CAN0.init_Mask(0, 0, 0x7FF); CAN0.init_Mask(1, 0, 0x7FF); CAN0.init_..
[아두이노] RFID-RC522를 이용한 RFID 태그 인식
·
Arduino
/*RFID-RC522 - 아두이노SDA - D10SCK - D13MOSI - D11MISO - D12IRQ - XGND - GNDRST - D93.3V - 3.3V스위치 - 아두이노SW_IN - D7SW_OUT - GND피에조 부저 - 아두이노+ - D8- - GND*/#include #include #include #define SW_PIN 7#define PIEZO_PIN 8#define RST_PIN 9#define SS_PIN 10bool sw_push;unsigned int sw_push_ms;String saved_tag_uid, scan_tag_uid;MFRC522 rfid(SS_PIN, RST_PIN);void setup() { // 초기화 Serial.begin(9600); pin..
[아두이노] 풀업 풀다운 저항 회로를 이용하여 입력 신호 플로팅 현상 해결
·
Arduino
플로팅 현상이란? 직역하면 "떠 있는, 떠다니는"이다. 신호 입력을 받는 핀에서 5V, GND 신호가 아닌 입력 받는 신호가 없을 때 일어난다. 아래 예제를 통해 더 알아보겠다. void setup() { Serial.begin(9600); pinMode(9, INPUT); } void loop() { Serial.println(digitalRead(9)); } 위 소스코드를 예제로 진행해 보겠다. 9번 핀을 입력 핀으로 설정하고 입력받은 결과를 출력하는 예제이다. 회로는 위와 같이 구성하였다. 스위치를 누르면 5볼트의 전원이 입력 핀에 인가되는 회로이다. 예상되는 결과로는 스위치를 누를 때마다 1을 결과로 출력 해야 하는데 중간중간 0과 1을 교차하며 결과를 출력하는 것을 볼 수 있다. 맨손으로 입력 ..
[아두이노] EEPROM 라이브러리를 이용한 비휘발성 메모리 저장
·
Arduino
#include void setup() { Serial.begin(9600); int value; EEPROM.get(0, value); Serial.print("변경 전 0번 메모리 값 : "); Serial.println(value); EEPROM.put(0, 111); EEPROM.get(0, value); Serial.print("변경 후 0번 메모리 값 : "); Serial.println(value); EEPROM.get(1, value); Serial.print("변경 전 1번 메모리 값 : "); Serial.println(value); EEPROM.put(1, 222); EEPROM.get(1, value); Serial.print("변경 후 1번 메모리 값 : "); Serial.pri..
[아두이노] PWM 라이브러리를 이용한 MG90 서보모터 제어
·
Arduino
글을 시작하기에 앞서 Servo 라이브러리를 이용한 서보모터 제어 예제를 먼저 보고 오면 좋을 거 같다. 회로는 아두이노와 다이렉트로 구성하고 PWM 파형을 관측할 수 있게 중간에 오실로스코프 핀을 연결해 놓았다. #include void setup() { Serial.begin(9600); InitTimersSafe(); SetPinFrequencySafe(9, 50); // 50Hz = 20ms } void loop() { Serial.println("pwmWrite 7 anglne 0"); pwmWrite(9, 7); delay(2000); Serial.println("pwmWrite 18 anglne 90"); pwmWrite(9, 18); delay(2000); Serial.println("pw..
[아두이노] Servo 라이브러리를 이용한 MG90 서보모터 제어
·
Arduino
가장 심플한 서보모터 회로도이다. #include Servo servo; void setup() { Serial.begin(9600); servo.attach(9); } void loop() { Serial.println("write angle 0"); servo.write(0); delay(2000); Serial.println("writeMicroseconds angle 0"); servo.writeMicroseconds(544); delay(2000); Serial.println("write angle 90"); servo.write(90); delay(2000); Serial.println("writeMicroseconds angle 90"); servo.writeMicroseconds(1472)..
[아두이노] PWM 기본 라이브러리 PWM.h ATimerDefs.h ATimerDefs.cpp BTimerDefs.h BTimerDefs.cpp 소스 코드
·
Arduino
PWM.h /* Copyright (c) 2012 Sam Knight Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom..
[아두이노] IR 적외선 리모컨 수신 데이터 0xFFFFFFFF 해결법
·
Arduino
#include int RECV_PIN = 11; IRrecv irrecv(RECV_PIN); decode_results results; void setup() { Serial.begin(9600); irrecv.enableIRIn(); } void loop() { if (irrecv.decode(&results)) { Serial.println(results.value, HEX); irrecv.resume(); } } FFFFFFFF 출력으로 문제된 대부분의 사람들이 위와 같은 예제 소스코드로 테스트를 했을 것이다. 그리고 IR 수신회로를 구성하여 리모컨을 눌렀을 때 위와 같이 FFFFFFFF의 데이터만 수신 했을것이다. #include int RECV_PIN = 11; IRrecv irrecv(REC..
[아두이노] 서보모터 기본 라이브러리 Servo.h Servo.cpp ServoTimers.h 소스 코드
·
Arduino
Servo.h /* Servo.h - Interrupt driven Servo library for Arduino using 16 bit timers- Version 2 Copyright (c) 2009 Michael Margolis. All right reserved. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later versio..