Nov 30, 2020

[Arduino code] Find an I2C address of a sensor using I2C scanner (IC2로 통신하는 센서의 주소 찾기)

- Supplies: Arduino board, I2C sensor
- How to connect?!

- Example code
#include <Wire.h>
 
 
void setup()
{
  Wire.begin();
 
  Serial.begin(9600);
  while (!Serial);             // Leonardo: wait for serial monitor
  Serial.println("\nI2C Scanner");
}
 

Nov 26, 2020

How to build Arduino IDE for Visual Studio 2019 (Visual Micro) (Visual Studio 2019에서 Arduino IDE 사용하기, 개발환경 구축)

Installation methods can be dependent on your program version.

0. First, install Visual Studio 2019.

1. In Menu bar, Click [Extensions]->[Manage Extensions].


2. Write 'arduino' -> Clink Download.


3. In the Pop-up window, Clink the ok button.

4. Restart the VS program and Clink the 'Create a new project'.


5.  Write 'arduino' and Clink the 'Arduino Empty Project'.


6. Write the Project name (ex) VS_Arduino_example).


7. Write some code in the blank sheet and check the version, board, and port. After then, click the upload button.


* You can find some example codes in the red marked button. 

Nov 24, 2020

LED + Slide switch + Lithium polymer (lipo.) battery charger + lipo. battery

- Goal: LED turn On/off with lipo battery charger circuit

- Supplies: LED, slide switch, Lipo charger (*SparkFun Lipo Charger Basic - Micro-USB), Lipo battery, register, wire, micro type USB

*https://www.sparkfun.com/products/10217

[Wring connection (left) and charging mode (right)]



[LED turn on (right sight) and off (left side)]





Nov 19, 2020

[Arduino code] Moving average filter (아두이노에서 구현한 이동평균 필터)

- Simple Arduino code to implement a moving average filter
- 이동평균 필터를 구현한 아두이노 코드
#define baud_rate 9600
#define low_window_size 5
#define high_window_size 20
//...
//...
int low_index = 0;
int high_index = 0;

float low_readings[low_window_size];
float high_readings[high_window_size];

float low_sum_measurement = 0;
float high_sum_measurement = 0;

float low_avg_measurement = 0;
float high_avg_measurement = 0;


void setup()
{
  
  //...
  //...
 Serial.begin(baud_rate); 
 //initialize **************************************************************
  for(int i = 0; i<low_window_size; i++){
    low_readings[i] = 0;
  }
  for(int k = 0; k<high_window_size; k++){
     high_readings[k] = 0;
  }
 
}

void loop()
{

  //...
  //...

  //moving average filter ***************************************************
  low_sum_measurement = low_sum_measurement - low_readings[low_index];
  high_sum_measurement = high_sum_measurement - high_readings[high_index];

  // sensor measurement
  low_readings[low_index] = measurement;
  high_readings[high_index] = measurement;
  
  low_sum_measurement = low_sum_measurement + low_readings[low_index];
  high_sum_measurement = high_sum_measurement + high_readings[high_index];
  
  low_index = low_index + 1;
  high_index = high_index + 1;

  if(low_index>=low_window_size){
    low_index = 0;
  }
  if(high_index>=high_window_size){
    high_index = 0;
  }

  low_avg_measurement = low_sum_measurement/low_window_size;
  high_avg_measurement = high_sum_measurement/high_window_size;
  
  // serial display ********************************************************
  Serial.print(measurement); Serial.print(", ");
  Serial.print(low_avg_measurement); Serial.print(",  ");
  Serial.print(high_avg_measurement);
  Serial.println();

}

As 'window size' increases, noise decreases but a time delay occurs.
window size 가 커질수록 노이즈는 줄어들지만 시간 지연 현상이 발생한다.

Nov 2, 2020

[Arduino project] Infrared (IR) control module kit using Arduino Uno

- Goal: Check the button address of IR remote controller. (IR 조종기의 버튼 주소 확인)

- Supplies: Arduino Uno, IR kit (ELB030102 (YwRobot), ...)

- 준비물: 아두이노 우노, 적외선 실험 키트

https://www.devicemart.co.kr/goods/view?no=1280305#goods_description

1. You need to install Arduino IR library. (아두이노 IR 라이브러리 설치 필요.) 

2. Arduino code: File => Example => IRremote => IRrecvDumpV2


3. Connect three output pins of the IR receiver to Arduino Uno.


4. Push the two buttons (ex. CH, 100+) of the IR transmitter.