본문 바로가기

전체 글144

아두이노 시리얼 통신 사용하기 (TTL USB연결, RealTime Serial Capture Program) 소프트웨어 시리얼 아두이노 우노의 경우에는 모든 핀이 가능 마스터 #include SoftwareSerial SofSerial(2,3); //2번을 rx 3번을 tx void setup(){ Serial.begin(115200); SoftSerial.begin(115200); } void loop(){ if(Serial.available()){ //시리얼모니터에서 받은 데이터가 있는지 여부 char c = Serial.read(); //있다면 그 데이터를 일기 SoftSerial.write(c); //SoftSerial을 통해 쓰기 } } 슬레이브 #include SoftwareSerial SofSerial(2,3); //2번을 rx 3번을 tx void setup(){ Serial.begin(9600).. 2021. 6. 17.
아두이노 LCD에 온습도 표기 /* 온습도 센서 예제 온도와 습도를 출력 라이브러리 DHT sensor library by Adafruit 와 Adafruit Unified Sensor by Adafruit를 아래 링크에서 설치 해야함 https://github.com/adafruit/DHT-sensor-library https://github.com/adafruit/Adafruit_Sensor http://www.devicemart.co.kr/ */ #include #include #include "DHT.h" // DHT 라이브러리 호출 #define DHTPIN 8 // 온습도 센서가 4번에 연결 #define DHTTYPE DHT11 // DHT11 온습도 센서 사용 DHT dht(DHTPIN, DHTTYPE); // DHT .. 2021. 6. 17.
아두이노 LCD 아두이노에서 스케치에서 라이브러리 포함하기에서 라이브러리 관리하기를 들어가 Liquid Crystal I2C를 다운받는다 파일에서 예제에서 Hello World 들어가기 //YWROBOT //Compatible with the Arduino IDE 1.0 //Library version:1.1 #include #include LiquidCrystal_I2C lcd(0x27,20,4); // set the LCD address to 0x27 for a 16 chars and 2 line display void setup() { lcd.init(); // initialize the lcd lcd.init(); // Print a message to the LCD. lcd.backlight(); lcd.set.. 2021. 6. 16.
아두이노 온습도 센서 ex) /* 온습도 센서 예제 온도와 습도를 출력 라이브러리 DHT sensor library by Adafruit 와 Adafruit Unified Sensor by Adafruit를 아래 링크에서 설치 해야함 https://github.com/adafruit/DHT-sensor-library https://github.com/adafruit/Adafruit_Sensor http://www.devicemart.co.kr/ */ #include "DHT.h" // DHT 라이브러리 호출 #define DHTPIN 8 // 온습도 센서가 4번에 연결 #define DHTTYPE DHT11 // DHT11 온습도 센서 사용 DHT dht(DHTPIN, DHTTYPE); // DHT 설정 (4,DHT11) v.. 2021. 6. 16.
아두이노 조도센서 조도 어떤 면이 받는 빛의 세기를 나타내는 값 조도센서 빛의 밝기에 따라 값이 바뀌는 저항 밝을 수록 조도 센서의 저항값이 감소 어두울수록 저항 값이 증가 ex) #define CDS_PIN A0 void setup(){ Serial.begin(115200); } void loop(){ int brightData = analogRead(CDS_PIN); Serial.print("bright : "); Serial.println(brightData); delay(1000); } ex2) #define CDS_PIN A0 #define LED_PIN 8 void setup(){ Serial.begin(115200); pinMode(LED_PIN,OUTPUT); } void loop(){ int brightD.. 2021. 6. 16.
아두이노 C언어 보호되어 있는 글 입니다. 2021. 6. 16.