BASIC4MCU | 질문게시판 | 토양 습도 센서와 네오픽셀 소스합치는 거 부탁드립니다.
페이지 정보
작성자 마마마 작성일2019-05-15 17:15 조회3,720회 댓글0건
https://www.basic4mcu.com/bbs/board.php?bo_table=gac&wr_id=8596
본문
수고가 많으십니다 마스터님
토양습도센서에서 나오는 시리얼 값을 이용해서 네오픽셀에 불이 들어오게 할려는데 소스를 합쳐주실 수 있나요??
-----------------네오픽셀------------------------
#include <Adafruit_NeoPixel.h>#define PIN 7 // 제어 신호핀#define NUMPIXELS 16 // 제어하고 싶은 LED 개수Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);int delayval = 500; // delay for half a secondvoid setup() {pixels.begin(); // This initializes the NeoPixel library.}void loop() {for(int i=0;i<NUMPIXELS;i++){// pixels.Color takes RGB values, from 0,0,0 up to 255,255,255pixels.setPixelColor(i, pixels.Color(0,150,0)); // Moderately bright green color.pixels.show(); // This sends the updated pixel color to the hardware.delay(delayval); // Delay for a period of time (in milliseconds).}}--------------------------토양습도센서-------------------------------------------------------------------------------------
#include <Wire.h>#include <LiquidCrystal_I2C.h>LiquidCrystal_I2C lcd(0x3F,16,2);int Sensor_pin = A1; // 토양수분센서 핀을 A1으로 설정int LED_R = 3; // 빨간색 LED 핀을 3번핀으로 설정int LED_G = 4; // 초록색 LED 핀을 4번핀으로 설정void setup(){Serial.begin(9600);lcd.init();lcd.backlight(); // 백라이트 ONpinMode(LED_R,OUTPUT); // 빨간색 LED핀을 출력으로 설정pinMode(LED_G,OUTPUT); // 초록색 LED핀을 출력으로 설정}void loop(){Serial.println(analogRead(Sensor_pin));// 센서값을 시리얼모니터로 전송delay(100); // 0.1초 간격으로 센서값 출력if(analogRead(Sensor_pin) > 400){ // 토양에 수분이 부족하면lcd.clear();digitalWrite(LED_R,HIGH); // 빨간색 LED ONdigitalWrite(LED_G,LOW);lcd.setCursor(0,0);lcd.print("Water, please"); // 'Water,please' 문구 출력}else{ // 토양에 수분이 충분하면lcd.clear();digitalWrite(LED_G,HIGH); // 초록색 LED ONdigitalWrite(LED_R,LOW);lcd.setCursor(0,1);lcd.print("Enough"); // 'Enough' 문구 출력}}
댓글 0
조회수 3,720등록된 댓글이 없습니다.