2015년 11월 29일 일요일

밸런싱 로봇 만들어 보기(Balancing robot)

 던전워즈
이번에는 밸런싱 로봇을 만들어보기로 했습니다.
밸런싱 로봇을 만들면서 가장힘들었던점은 기구부를 만드는 거였네요.
마땅히 기구부를 구할 방법이 없다보니 힘들게 겨우 만들었습니다.



먼저 제어 회로쪽입니다.
나노 호환 모듈과 hc-06 블루투스, mpu6050 6축 자이로 가속도 센서 및 TB6612FNG듀얼채널 모터 드라이버를 사용했습니다.
점퍼선을 없애기 위해서 모두 pcb에 배선을 했네요.  노란색 콘덴서는 680마이크로 패럿짜리 전원부에 결선되어 있습니다.
납땜 하는것 너무 싫어 하는데 암튼 몇시간에 걸쳐서 완성했습니다. 

일단 기구부와 조립한 모습입니다.
기어드 모터는 저렴한 TT모터라고 2륜 구동차 구매 하면서 딸려온것을 활용했습니다.
가장힘들었던점은 TT모터를 고정하는 브라켓이 마땅한게 없어서 거의 못만들뻔했네요.
아래 사진에 보이는 배선들은 전원부 배선과 모터로 연결되는 선들입니다. 하네스 커넥터를 사용해서 깔끔하게 연결했습니다.


기어드 모터를 고정시키는 브라켓은 굴러다니고 있는 어린이용 나무블럭을 활용해서 만들었습니다. ㅋㅋㅋㅋㅋㅋㅋㅋ
마침 사이즈가 적당하지 않았다면 밸런싱 로봇은 물건너 가지 않았을까 생각이 드네요.

2개의 건전지 홀더를 사용했는데, 아래쪽은 4개의 AA건전지 위에 보이는것은 9V건전지용홀더입니다.
상판은 회로의 PCB를 그대로 서포터를 사용해서  고정하고 하판은 포맥스판을 대충 잘라서 나사로 고정했습니다.
건전지 홀더는 양면테이프를 활용해서 접착을 시켰네요.

모터드라이버의 출력은 헤더핀에 연결하고 각모터에 헤더핀용 점퍼선을 납땜해서 연결했습니다. 모터 방향이 잘못연결된경우 편리하게 다시 배선할 수 있네요.
TB6612FNG모터 드라이버는 알리에서 개당 3000원정도에 4개를 구했했는데, 한동안 짱박혀 있다가 이제야 써먹어 보내요.
저 모터 드라이버의 장점은 1.2A의 비교적 쓸만한 정도의 전류공급이 가능하고 무엇보다 매우 작은 크기라는 것입니다.


거의 아두이노 호환 보드를 사용중인데, 역시 알리에서 구매했습니다. 저렴하게 다량구매해서 잘써먹고 있네요.

mpu6050 6축 자이로 가속도 센서입니다. 각도 측정할때 많이 사용되죠, 관련된 칼만필터나 이런것도 있어서 손쉽게 사용가능합니다.

휴대폰의 앱을 통해서 제어를 하기 위해서 hc-06블루투스 모듈을 사용했습니다. 

밸런싱 로봇용 전용앱을 만들어야 하는데, 일단하나부터 열까지 새로 만들자면 너무 일이 많아지니 기존에 탱크나, 2wd카에서 사용했던 앱에 쓸쩍 다리 하나 걸쳐서
완성했습니다.
PID제어를 하고 있는데, 관련 상수를 손쉽게 조정할 수 있는 인터페이스를 추가했고,
일단 전, 후, 좌, 우 제어가 되도록 하기위한 조정버튼도 추가했습니다.






드디어 완성된 밸런싱 로봇!!



밸런싱 로봇 제어 소스입니다. 도움이 되지 않을것 같지만 일단 첨부해둡니다.
안드로이드와 블루투스 제어쪽이 빠진 소스입니다.
소스다운로드


2015년 10월 30일 금요일

구글플레이 게임서비스 클라우드저장 기능 사용해 보기(Google play game service saved game)

 던전워즈

구글플레이 서비스에서 유용한점 하나가 클라우드 저장기능입니다.
서버가 없는 게임인경우 게임데이터를 구글클라우드 서버에 저장하거나 가져오기를 통해서 사용자의 데이터를 안전하게 보관할 수 있습니다.

아래 주소에서 유니티용 플러그인을 다운로드 할 수 있습니다.
https://github.com/playgameservices/play-games-plugin-for-unity

구글플레이 게임서비스 이용에 관한 전반적인 사항은 검색을 통해서 확인하시기 바랍니다.

클라우드 저장기능사용에 대한 핵심적인 부분만 코드로 보여드립니다.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
using UnityEngine;
using System.Collections;
using GooglePlayGames;
using GooglePlayGames.BasicApi;
using GooglePlayGames.BasicApi.SavedGame;
public static class CGoogleplayGameServiceManager
{
    //게임서비스 플러그인 초기화시에 EnableSavedGames()를 넣어서 저장된 게임 사용할 수 있게 합니다.
    //주의 하실점은 구글플레이 개발자 콘솔의 게임서비스에서 해당게임의 세부정보에서 저장된 게임 사용을 
    //하도록 설정하셔야 합니다.
    public static void Init()
    {
        PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder().EnableSavedGames().Build();
        PlayGamesPlatform.InitializeInstance(config);
        //
        PlayGamesPlatform.DebugLogEnabled = false;
        //Activate the Google Play gaems platform
        PlayGamesPlatform.Activate();
    }
    //인증여부 확인
    public static bool CheckLogin()
    {
        return Social.localUser.authenticated;
    }
    //--------------------------------------------------------------------
    //게임 저장은 다음과 같이 합니다.
    public static void SaveToCloud()
    {
        if (!CheckLogin()) //로그인되지 않았으면
        {
            //로그인루틴을 진행하던지 합니다.
            return;
        }
        //파일이름에 적당히 사용하실 파일이름을 지정해줍니다.
        OpenSavedGame("사용할파일이름"true);
    }
    static void OpenSavedGame(string filename, bool bSave)
    {
        ISavedGameClient savedGameClient = PlayGamesPlatform.Instance.SavedGame;
        if (bSave)
            savedGameClient.OpenWithAutomaticConflictResolution(filename, DataSource.ReadCacheOrNetwork, ConflictResolutionStrategy.UseLongestPlaytime, OnSavedGameOpenedToSave); //저장루틴진행
        else
            savedGameClient.OpenWithAutomaticConflictResolution(filename, DataSource.ReadCacheOrNetwork, ConflictResolutionStrategy.UseLongestPlaytime, OnSavedGameOpenedToRead); //로딩루틴 진행
    }
    //savedGameClient.OpenWithAutomaticConflictResolution호출시 아래 함수를 콜백으로 지정했습니다. 준비된경우 자동으로 호출될겁니다.
        static void OnSavedGameOpenedToSave(SavedGameRequestStatus status, ISavedGameMetadata game)
        {
            if (status == SavedGameRequestStatus.Success)
        {
            // handle reading or writing of saved game.
                //파일이 준비되었습니다. 실제 게임 저장을 수행합니다.
                //저장할데이터바이트배열에 저장하실 데이터의 바이트 배열을 지정합니다.
                SaveGame(game, "저장할데이터바이트배열", DateTime.Now.TimeOfDay);
        }
        else
        {
            //파일열기에 실패 했습니다. 오류메시지를 출력하든지 합니다.
        }
    }
    static void SaveGame(ISavedGameMetadata game, byte[] savedData, TimeSpan totalPlaytime)
    {
        ISavedGameClient savedGameClient = PlayGamesPlatform.Instance.SavedGame;
        SavedGameMetadataUpdate.Builder builder = new SavedGameMetadataUpdate.Builder();
        builder = builder
            .WithUpdatedPlayedTime(totalPlaytime)
            .WithUpdatedDescription("Saved game at " + DateTime.Now);
        /*
        if (savedImage != null)
        {
            // This assumes that savedImage is an instance of Texture2D
            // and that you have already called a function equivalent to
            // getScreenshot() to set savedImage
            // NOTE: see sample definition of getScreenshot() method below
            byte[] pngData = savedImage.EncodeToPNG();
            builder = builder.WithUpdatedPngCoverImage(pngData);
        }*/
        SavedGameMetadataUpdate updatedMetadata = builder.Build();
        savedGameClient.CommitUpdate(game, updatedMetadata, savedData, OnSavedGameWritten);
    }
    static void OnSavedGameWritten(SavedGameRequestStatus status, ISavedGameMetadata game)
    {

        if (status == SavedGameRequestStatus.Success)
        {
            //데이터 저장이 완료되었습니다.
        }
        else
        {
            //데이터 저장에 실패 했습니다.
        }
    }
    //----------------------------------------------------------------------------------------------------------------
    //클라우드로 부터 파일읽기
    public static void LoadFromCloud()
    {
        if (!CheckLogin())
        {
            //로그인되지 않았으니 로그인 루틴을 진행하던지 합니다.
            return;
        }
        //내가 사용할 파일이름을 지정해줍니다. 그냥 컴퓨터상의 파일과 똑같다 생각하시면됩니다.
        OpenSavedGame("사용할파일이름"false);
    }
    static void OnSavedGameOpenedToRead(SavedGameRequestStatus status, ISavedGameMetadata game)
    {
        if (status == SavedGameRequestStatus.Success)
        {
            // handle reading or writing of saved game.
            LoadGameData(game);
        }
        else
        {
            //파일열기에 실패 한경우, 오류메시지를 출력하던지 합니다.
        }
    }
    //데이터 읽기를 시도합니다.
    static void LoadGameData(ISavedGameMetadata game)
    {
        ISavedGameClient savedGameClient = PlayGamesPlatform.Instance.SavedGame;
        savedGameClient.ReadBinaryData(game, OnSavedGameDataRead);
    }
    static void OnSavedGameDataRead(SavedGameRequestStatus status, byte[] data)
    {
            if (status == SavedGameRequestStatus.Success)
            {
                // handle processing the byte array data
                //데이터 읽기에 성공했습니다.
                //data 배열을 복구해서 적절하게 사용하시면됩니다.
            }
            else
            {
                //읽기에 실패 했습니다. 오류메시지를 출력하던지 합니다.
            }
    }
}
cs

2015년 9월 13일 일요일

네이버앱스토어 인앱 영수증 검증 c# 버전(Naver App Store receipt verification)

 던전워즈

네이버의 경우 구글과 같은 형태로 영수증을 발급하고 있습니다.
그렇기 때문에 구글 결제모듈과 동일한 방법으로 영수증 검증을 하면되는데 차이점은
네이버결제 데이터에는 한글같은게 포함되기 때문에 약간의 수정이 있어야 합니다.

아래 코드는 네이버 결제 코드 검증 루틴의 코드입니다.

구글 검증루틴과 차이점은 아래 코드에서 진하게 표시해놓은(Encoding.UTF8.GetBytes(Message)) 부분입니다.

바운시 캐슬 암호화 루틴은 구글 결제 코드 예제에 보시면 포함되어 있고, 라이브러리를 포함하기 힘든경우에는
바운시 캐슬 사이트에서 소스 코드를 직접 받아서 사용하시면됩니다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
using Org.BouncyCastle.Security;
using Org.BouncyCastle.Crypto;
using Org.BouncyCastle.Crypto.Parameters;
using System.Security.Cryptography;
using System;
public class NaverSignatureVerify
    {
        RSAParameters _rsaKeyInfo;
        public NaverSignatureVerify(String strNaverPublicKey)
        {
            RsaKeyParameters rsaParameters = (RsaKeyParameters)PublicKeyFactory.CreateKey(Convert.FromBase64String(strNaverPublicKey));
            byte[] rsaExp = rsaParameters.Exponent.ToByteArray();
            byte[] Modulus = rsaParameters.Modulus.ToByteArray();
            // Microsoft RSAParameters modulo wants leading zero's removed so create new array with leading zero's removed
            int Pos = 0;
            for (int i = 0; i < Modulus.Length; i++)
            {
                if (Modulus[i] == 0)
                {
                    Pos++;
                }
                else
                {
                    break;
                }
            }
            byte[] rsaMod = new byte[Modulus.Length - Pos];
            Array.Copy(Modulus, Pos, rsaMod, 0, Modulus.Length - Pos);
            // Fill the Microsoft parameters
            _rsaKeyInfo = new RSAParameters()
            {
                Exponent = rsaExp,
                Modulus = rsaMod
            };
        }
        public bool Verify(String Message, String Signature)
        {
            if (Application.platform == RuntimePlatform.Android)
            {
                using (RSACryptoServiceProvider rsa = new RSACryptoServiceProvider())
                {
                    try
                    {
                        rsa.ImportParameters(_rsaKeyInfo);
                        return rsa.VerifyData(Encoding.UTF8.GetBytes(Message)"SHA1", Convert.FromBase64String(Signature));
                    }
                    catch (System.Exception ex)
                    {
#if NEED_LOG
                        Debug.Log("Verify failed : " + ex.ToString());
#endif
                        return false;
                    }
                }
            }
            else
            {
                return true;
            }
        }
    }
cs

2015년 7월 25일 토요일

MPU6050 사용해보기

 던전워즈
자이로 와 가속도 센서가 포함된 센서입니다.
매우 유명하여 딱히 설명할 필요가 없는 센서인데,
예제또한 풍부합니다.
하지만 깔끔하게 센서제어 및 액세스에 관련한 부분만 만들어진것은 안보이는것 같아
제가 참고 했던 예제중 하나를 클래스로 래핑하여, 라이브러리화 했습니다.

사용법은 아래와 같습니다.

첨부 파일을 아두이노 라이브러리에 추가 하시고 사용하면됩니다.
칼만필터라는 예제를 수정한 버전인데 혹 이미 같은 라이브러리를 추가해놓으신경우에는
에러가 날 수 도 있겠습니다.
그런경우에는 CMPU6050.h 파일만 칼만필터 라이브러리 폴더내에 복사해 넣으시면되겠습니다.

첨부라이브러리
구글 블러그는 첨부 파일기능이 없어 불편하네요..



일전에 밸런싱 로봇을(http://eltgroup.tistory.com/266) 만들때 아래 라이브러리를 활용하여 만든것이니, 동작에 별문제 없다고 생각합니다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <Arduino.h>
#include <Wire.h>
#include <Kalman.h>
#include <CMPU6050.h>
//mpu6050 매니저입니다. 단순히 누군가 만들어놓은 유명한 예제에서 mpu6050부분만 뽑아 클래스화 시킨겁니다.
CMpu6050Manager g_Mpu6050;
void setup()
{
  g_Mpu6050.Init(); //setup에서 반드시 한번 호출해 줍니다.
}
void loop()
{
  //매 루프마다 호출되게 해줍니다.
  g_Mpu6050.Update();
  
  //x값은 -90 ~ 90
  //y값은 -180 ~ 180범위
  //상보 필터(Complementary Filter) 
  float companglex = g_Mpu6050.GetCompAngleX();
  float compangley = g_Mpu6050.GetCompAngleY();
  
  //칼만 필터, 
  float kalmananglex = g_Mpu6050.GetKalAngleX();
  float kalmanangley = g_Mpu6050.GetKalAngleY();
}
cs

2015년 7월 12일 일요일

유니티 애즈 동영상광고(Unity Ads)

 던전워즈
여러광고 플랫폼이 있는데 그중에서 동영상 광고 플랫폼이 있습니다.
유니티 애즈라고 생긴지 오래된 플랫폼은 아닌것 같은데,
게임내에서 아무튼 광고를 보고 나면 뭔가 보상을 주는 형태를 계획하고 계신경우 사용하기에 적당해 보입니다.


일단 유니티 애즈 사이트에 접속하고 가입을 합니다.


왼쪽에 메뉴중에서 게임 탭을 선택하시면 아마 아래 사진과 비슷한 화면을 볼 수 있을 겁니다.
여기에서 새 게임 추가를 눌러서 몇단계의 정보 입력 단계를 거친 후 게임 추가를 완료합니다.
위사진에 보면 게임 ID라는 것이 보일겁니다. 
이게임 ID를 잘 기록해 둡니다.

이제 유니티 애즈용 유니티 플로그인을 아래 유니티 애셋 스토어를 통해서 다운로드 받습니다.


유니티 프로젝트에 임포트 하시면 되고 사용법은 매우 간단합니다.


using UnityEngine.Advertisements; 를하시고

아래 코드를 통해서 초기화를 해줍니다.

두개의 인자를 받는데, 첫번째가 위에서 게임을 등록할때 받은 게임 ID입니다.
두번째는 테스트모드로 초기화를 할건지 실제 모드로 초기화 할건지를 나타냅니다.
일단 테스트모드(true)로 설정해서 테스트를 해보시고 문제 없으면 실제모드(false)로 설정하면 되겠습니다.
주의 : 실제 배포할때 테스트 모드로 그대로 설정하고 배포하는 실수를 하지 않기를
void InitUnityAds()
{
Advertisement.Initialize("위에서 받은 게임ID", false);
}

원한는 시점에 동영상 광고 보여주기를 호출하시고 유저가 동영상을 다봤는지 스킵했는지등에 따라서 보상을 주던지 하면되겠습니다.
동영상 보여주기는 아래 코드를 통해서 가능합니다.


Advertisement.isReady() 를 통해서 동영상 광고가 준비 되었는지 확인하고

리턴값이 true이면


아래 코드를 통해서 동영상을 보여주면됩니다.
ShowOptions라는게 있는데
resultCallback에 콜백 델리게이트를 등록하시면
동영상 플레이의 결과를 콜백을 통해서 받을 수 있습니다.

//동영상 보여주기
void ShowUnityAds()
{
   if (Advertisement.isReady()) //동영상이 준비 되었으면
   {
      ShowOptions opt = new ShowOptions();
      opt.resultCallback = OnShowResult;
      Advertisement.Show(null, opt);
   }
}

//동영상 플레이 결과에 따라서 리워드를 지급하든지 자신의 게임에 맞는 처리를 하면됩니다.
void OnShowResult(ShowResult ret)
{
   switch(ret)
   {
      case ShowResult .Failed:      //동영상 보여주기 실패한경우
break;
      case ShowResult .Skipped:   //유저가 중간에 동영상을 스킵한경우
break;
      case ShowResult .Finished:  //유저가 동영상을 끝까지 본경우
break;
   }
}

유니티에서 직접 만든거라 기타 광고 플랫폼 보다 사용하기 매우 수월할 편입니다.
아래 클래스는 예제코드 입니다.
//----------------------------------------------------------------------------------------------------------------
using UnityEngine.Advertisements;
public static class CUnityAdsManager
{
//광고 초기화(게임시작시에 어딘가에서 한번 호출해 줍니다.)
public static void InitUnityAds()
{
Advertisement.Initialize("위에서 받은 게임ID", false);
}

//동영상이 준비되었는지 확인합니다.
public static bool CheckAds()
{
     return Advertisement.isReady();
}

//광고 보여주기, 리턴값은 광고 보여주기 시도가 성공했는지
public static bool ShowUnityAds()
{
   if (Advertisement.isReady()) //동영상이 준비 되었으면
   {
          ShowOptions opt = new ShowOptions();
      opt.resultCallback = OnShowResult;
          Advertisement.Show(null, opt);
 return true;
   }

return false;
}

//광고 시청결과
public static void OnShowResult(ShowResult ret)
{
   switch(ret)
   {
          case ShowResult .Failed:      //동영상 보여주기 실패한경우
break;
      case ShowResult .Skipped:   //유저가 중간에 동영상을 스킵한경우
break;
      case ShowResult .Finished:  //유저가 동영상을 끝까지 본경우
break;
   }
}

}

사용예)
1. 게임 시작시에 초기화 코드에 다음을 호출해 줍니다.

CUnityAdsManager.InitUnityAds();

2. 대부분 동영상광들이 어떤 버튼을 눌렀을때 광고를 보여주고 보상을 주는 형태로 많이 적용하는것 같습니다.

  if (CUnityAdsManager.CheckAds())
  {
       //동영상이 준비되었으면 버튼을 보이거나 합니다.
  }

3. 버튼같은걸 눌렀을때 동영상을 보여줍니다.
    CUnityAdsManager.ShowUnityAds();

4. 결과 콜백함수 내부에서 동영상 시청 결과에 따라서 보상을 주던지 합니다.(위의 OnShowResult 함수내부를 자신에 맞게 적당히 수정하세요.)

아래 링크에 예제 프로젝트를 만들어 두었습니다.
http://www.datafilehost.com/d/0c883fb9

2015년 5월 7일 목요일

아두이노 나노

 던전워즈
원문: http://www.arduino.cc/en/Main/ArduinoBoardNano


Overview(개요)

The Arduino Nano is a small, complete, and breadboard-friendly board based on the ATmega328 (Arduino Nano 3.x) orATmega168 (Arduino Nano 2.x). It has more or less the same functionality of the Arduino Duemilanove, but in a different package. It lacks only a DC power jack, and works with a Mini-B USB cable instead of a standard one. The Nano was designed and is being produced by Gravitech.
아두이노 나노는 작고 완전한, ATmega328(아두이노 나노 3.x) 또는 ATmega168(아두이노 나노 2.x)에 기반한 브레드보드 친화적인 보드이다. 이것은 아두이노 Duemilanove의 같은 기능과 비교했을때 거의 유사하다. 하지만 이들은 다른패키지다. 나노는 DC 파워 젝을 가지고 있지 않지만, 대신에 표준 Mini-B usb 케이블로 작업 할 수 있다. 나노는 Gravitech에 의해 디자인되고 생산되었다.

Schematic and Design(도식과 디자인)

Arduino Nano 3.0 (ATmega328): schematicEagle files.
Arduino Nano 2.3 (ATmega168): manual (pdf), Eagle filesNote: since the free version of Eagle does not handle more than 2 layers, and this version of the Nano is 4 layers, it is published here unrouted, so users can open and use it in the free version of Eagle.

Specifications(상세):

MicrocontrollerAtmel ATmega168 or ATmega328
Operating Voltage (logic level)5 V
Input Voltage (recommended)7-12 V
Input Voltage (limits)6-20 V
Digital I/O Pins14 (of which 6 provide PWM output)
Analog Input Pins8
DC Current per I/O Pin40 mA
Flash Memory16 KB (ATmega168) or 32 KB (ATmega328) of which 2 KB used by bootloader
SRAM1 KB (ATmega168) or 2 KB (ATmega328)
EEPROM512 bytes (ATmega168) or 1 KB (ATmega328)
Clock Speed16 MHz
Dimensions0.73" x 1.70"
Length45 mm
Width18 mm
Weigth5 g
운용 전압은 5v, 입력전압은 7 ~ 12v가 권장되며, 6 ~ 20v까지가 한계이다.
14개의 디지털 입출력 핀을 가지며, 이중 6개는 pwm출력이 가능하다.
8개의 아날로그 입력핀을 가지고 있다.
입출력핀의 전류는 핀당 40mA이며, 16KB(ATmega168) 또는 32KB(ATmega328)의 플래시 메모리를 가지는데 이중 2KB를 부트로더가 사용한다.
1KB(ATmega168)또는 2KB(ATmega328)의 스태틱 메모리를 가지고 있으며, 512바이트 또는 1KB의 EEPROM을 가지고 있다.
클럭스피드는 16MHz이며, 0.73인치 * 1.70인치크기다.

Power(전원):

The Arduino Nano can be powered via the Mini-B USB connection, 6-20V unregulated external power supply (pin 30), or 5V regulated external power supply (pin 27). The power source is automatically selected to the highest voltage source.
아두이노 나노는 Mini-B usb연결을 통해서 전원을 공급하거나, 6 ~ 20v의 정제되지 않은 외부전원(30번핀) 또는 5v의 정제된 외부 파워 공급(27번핀)이 가능하다. 파워 공급원은 가장높은 전압 소스로 부터 자동선택된다.

Memory(메모리)

The ATmega168 has 16 KB of flash memory for storing code (of which 2 KB is used for the bootloader); the ATmega328has 32 KB, (also with 2 KB used for the bootloader). The ATmega168 has 1 KB of SRAM and 512 bytes of EEPROM (which can be read and written with the EEPROM library); the ATmega328 has 2 KB of SRAM and 1 KB of EEPROM.
ATmega168은 코드 저장을 위해 16KB의 플래시 메모리를 가진다(2KB는 부트로더가 사용중이다);
ATmega328은 32KB를 가지고 있다(역시 2KB를 부트로더가 사용한다).
ATmega168은 1KB의 SRAM과 512 바이트의 EEPROM(EEPROM 라이브러리로 읽거나 쓰기가 가능)
을 가지고, Atmega328은 2KB의 SRAM과 1KB의 EEPROM을 가진다.

Input and Output(입력과 출력)

Each of the 14 digital pins on the Nano can be used as an input or output, using pinMode()digitalWrite(), anddigitalRead() functions. They operate at 5 volts. Each pin can provide or receive a maximum of 40 mA and has an internal pull-up resistor (disconnected by default) of 20-50 kOhms. In addition, some pins have specialized functions:
나노에 있는 14개의 디지털핀 각각은 pinMode()digitalWrite()digitalRead()함수를 통해서
입출력에 사용될 수 있다. 이핀들은 5V전압으로 운용되고, 각각의 핀들은 최대 40mA의 전류를 받거나
내보낼 수 있으며, 내부에 20 ~ 50K옴의 풀업 저항을 가진다(기본적으로 연결되어있지는 않다).
부가적으로, 몇개의 핀들은 특별한 기능을 가지고 있다.
  • Serial: 0 (RX) and 1 (TX). Used to receive (RX) and transmit (TX) TTL serial data. These pins are connected to the corresponding pins of the FTDI USB-to-TTL Serial chip.
  • External Interrupts: 2 and 3. These pins can be configured to trigger an interrupt on a low value, a rising or falling edge, or a change in value. See the attachInterrupt() function for details.
  • PWM: 3, 5, 6, 9, 10, and 11. Provide 8-bit PWM output with the analogWrite() function.
  • SPI: 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK). These pins support SPI communication, which, although provided by the underlying hardware, is not currently included in the Arduino language.
  • LED: 13. There is a built-in LED connected to digital pin 13. When the pin is HIGH value, the LED is on, when the pin is LOW, it's off.
  • 시리얼 : 0(RX) 1(TX). TTL 시리얼 데이터를 수신(RX) 또는 송신(TX)한다. 이 핀들은 FTDI USB-to-TTL 시리얼칩의 해당하는 핀에 연결되어있다.
  • 외부인터럽트 : 2와 3. 이들핀은 low값, 상승에지, 하강에지값에 대해서 인터럽트를 트리거할 수 있게 설정가능하다. attachInterrupt()함수를 통해서 자세한것을 보라.
  • SPI:10(SS), 11(MOSI), 12(MISO), 13(SCK). 이 핀들은 SPI통신을 지원한다, 근본적으로 하드웨어를 통해서 공급되지만,
  • 현재는 아두이노 언어에 포함되어있지 않다.
  • LED: 13번. 이것은 13번 디지털핀에 연결된 내부장착 LED이다. 핀의 값이 HIGH일때 LED는 켜지며, LOW일때 꺼진다.

The Nano has 8 analog inputs, each of which provide 10 bits of resolution (i.e. 1024 different values). By default they measure from ground to 5 volts, though is it possible to change the upper end of their range using theanalogReference() function. Analog pins 6 and 7 cannot be used as digital pins. Additionally, some pins have specialized functionality:
나노는 8개의 아날로그 입력을 가지며, 각각은 10비트 해상도를 지원한다(예 1024개의 다른값들).
기본적으로 이들은 그라운드 ~ 5V까지 측정하는데, analogReference() 함수를 사용해서 이 범위의 상한 값을 변경하는 것이 가능하다. 아날로그 핀 6과 7은 디지털 핀으로 사용될 수 없다. 부가적으로, 몇개의 핀은
특별한 기능을 가진다.
  • I2C: A4 (SDA) and A5 (SCL). Support I2C (TWI) communication using the Wire library (documentation on the Wiring website).
  • I2C: A4(SDA), A5(SCL).  Wire 라이브러리를 통한 I2C(TWI) 통신을  지원한다.

There are a couple of other pins on the board:
  • AREF. Reference voltage for the analog inputs. Used with analogReference().
  • Reset. Bring this line LOW to reset the microcontroller. Typically used to add a reset button to shields which block the one on the board.
  • AREF : 아날로그 입력의 기준전압. analogReference()함수와 이용된다.
  • Reset : LOW값을 가해서 마이크로컨트롤러를 리셋시킨다. 일반적으로 쉴드의 보드에 리셋버튼을 추가하는것에 사용된다.

Communication(통신)

The Arduino Nano has a number of facilities for communicating with a computer, another Arduino, or other microcontrollers. The ATmega168 and ATmega328 provide UART TTL (5V) serial communication, which is available on digital pins 0 (RX) and 1 (TX). An FTDI FT232RL on the board channels this serial communication over USB and the FTDI drivers (included with the Arduino software) provide a virtual com port to software on the computer. The Arduino software includes a serial monitor which allows simple textual data to be sent to and from the Arduino board. The RX and TX LEDs on the board will flash when data is being transmitted via the FTDI chip and USB connection to the computer (but not for serial communication on pins 0 and 1).
아두이노나노는 컴퓨터, 다른아두이노, 또는 다른 마이크로 컨트롤러와 통신하기위한 기능들을 가지고 있다.
ATmega168과 ATmega328은 UART TTL (5V)시리얼 통신을 지원하며, 디지털핀 0(RX)과 1(TX)를 통해서이용할 수 있다. 이시리얼의 보드의 채널은 FTDI FT232RL 시리얼 통신칩으로 USB를 통해서 통신하며, FTDI drivers는 컴퓨터에 가상의 com포트를 공급한다. 아두이노 소프트웨어는 시리얼 모니터를 포함하는데, 단순한 텍스트형 데이터를 아두이노에 보내거나 받을 수 있다.보드의 RX, TX LED들은  FTDI칩이 USB연결을 통해서 컴퓨터에 연결되어, 데이터를 전송할때 작동한다(핀0과 1을 통한 통신일때는 작동하지 않음).
SoftwareSerial library allows for serial communication on any of the Nano's digital pins.
The ATmega168 and ATmega328 also support I2C (TWI) and SPI communication. The Arduino software includes a Wire library to simplify use of the I2C bus; see the documentation for details. To use the SPI communication, please see theATmega168 or ATmega328 datasheet.
 SoftwareSerial라이브러리는 나노의 임의의 디지털핀을 통한 시리얼 통신을 지원한다.
ATmega168이나 Atmega328은 I2C(TWI)와 SPI통신 또한 지원한다. 아두이노 소프트웨어는 I2C버스를 이용하기위한 간략한 Wire라이브러리를 포함하는데, 자세한 것은 documentation를 보라.
SPI통신을 사용하기 위해, ATmega168 또는 ATmega328의 데이터 시트를 보라.

Programming(프로그래밍)

The Arduino Nano can be programmed with the Arduino software (download). Select "Arduino Diecimila, Duemilanove, or Nano w/ ATmega168" or "Arduino Duemilanove or Nano w/ ATmega328" from the Tools > Board menu (according to the microcontroller on your board). For details, see the reference and tutorials.
아두이노 나노는 아두이노 소프트웨어를 통해서 프로그램될 수 있다(download). Tools > Board메뉴의
"Arduino Diecimila, Duemilanove, 또는 Nano w/ ATmega168" 또는 "Arduino Duemilanove 또는 Nano w/ ATmega328" 보드를 선택한다(당신의 보드가 사용하는 마이크로 컨트롤러에 맞는것으로). 자세한것은
reference와 tutorials을 보라.
The ATmega168 or ATmega328 on the Arduino Nano comes preburned with a bootloader that allows you to upload new code to it without the use of an external hardware programmer. It communicates using the original STK500 protocol (referenceC header files).
아두이노 나노의 Atmega168또는 ATmega328에는 미리 bootloader가 구워져 있으며, 이것은 외부의 하드웨어 프로그래머 장치 없이 새로운 코드를 업로드 할 수 있게 한다. 이것은 오리지널 STK500 프로토콜을 통해서 통신한다(referenceC header files).
You can also bypass the bootloader and program the microcontroller through the ICSP (In-Circuit Serial Programming) header using Arduino ISP or similar; see these instructions for details.
당신은 부트로더를 우회할 수 있으며, Arduino ISP 또는 이와 유사한 것을 사용해 ICSP헤더(인서킷 시리얼프로그래밍)를 통해서 마이크로 컨트롤러를 프로그램할 수 있다. 자세한것은 these instructions를 보라.

Automatic (Software) Reset(소프트웨어형태의 자동리셋)

Rather then requiring a physical press of the reset button before an upload, the Arduino Nano is designed in a way that allows it to be reset by software running on a connected computer. One of the hardware flow control lines (DTR) of theFT232RL is connected to the reset line of the ATmega168 or ATmega328 via a 100 nanofarad capacitor. When this line is asserted (taken low), the reset line drops long enough to reset the chip. The Arduino software uses this capability to allow you to upload code by simply pressing the upload button in the Arduino environment. This means that the bootloader can have a shorter timeout, as the lowering of DTR can be well-coordinated with the start of the upload.
아두이노 나노는 업로드 전에 물리적형태의 리셋버튼을 누르는것을 요구하기 보다는, 연결된 컴퓨터에서 소프트웨어 형태로 리셋 할 수 있게 디자인되었다.
This setup has other implications. When the Nano is connected to either a computer running Mac OS X or Linux, it resets each time a connection is made to it from software (via USB). For the following half-second or so, the bootloader is running on the Nano. While it is programmed to ignore malformed data (i.e. anything besides an upload of new code), it will intercept the first few bytes of data sent to the board after a connection is opened. If a sketch running on the board receives one-time configuration or other data when it first starts, make sure that the software with which it communicates waits a second after opening the connection and before sending this data.