728x90

HC-SR04

출처 : HC-SR04 초음파 거리센서 - 아두이노
Ultrasonic HC-SR04 library for Arduino IDE - GitHub

라이브러리 설치

Ultrasonic 폴더를 arduino\libraries 디렉토리에 복사

배선

코드

#include <Ultrasonic.h>

Ultrasonic ultrasonic(12,13); // (Trig PIN,Echo PIN)

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600); 
}

void loop() {
  // put your main code here, to run repeatedly:
  Serial.print(ultrasonic.Ranging(CM)); // CM or INC
  Serial.println(" cm" );
  delay(100);
}

결과

728x90
728x90

출처 : arduino IDE (1.6.9) 최신판 Windows 사용자 설치 방법 (아두이노+ 블루투스 = 블루이노(BlueInno)) |작성자 빌리

Blueinno2 보드 추가

[추가적인 보드 매니저 URLs]에 URL 설정

URL : https://github.com/blueinno/blueinno2.archive/raw/master/package_blueinno2_102_index.json

Hello World

// test code for sending keystrokes from arduino
// to computer via HID bluetooth module
void setup() {
  Serial.begin(115200); // begin serial communication at 115200 baud rate
}
 
void loop() {
  Serial.println("hello world"); // write hello world
  delay(1000); // delay one second
}

컴파일

실행결과

728x90
728x90

출처 : Analog Read Serial

배선

소스

/*
  AnalogReadSerial
  Reads an analog input on pin 0, prints the result to the serial monitor.
  Graphical representation is available using serial plotter (Tools > Serial Plotter menu)
  Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.

  This example code is in the public domain.
*/

// the setup routine runs once when you press reset:
void setup() {
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
}

// the loop routine runs over and over again forever:
void loop() {
  // read the input on analog pin 1:
  int sensorValue = analogRead(A1);
  // print out the value you read:
  Serial.println(sensorValue);
  delay(1);        // delay in between reads for stability
}

결과

728x90

+ Recent posts