질문게시판 > 답변 : 아두이노 소스 코드 길이가 너무 길어져서 질문이 있습니다.

인기검색어 > 아두이노 센서 ATMEGA128

최신글 질문게시판 동영상강좌 가입하기

▼ BASIC4MCU 후원업체 신제품 정보 ▼

▲ BASIC4MCU 후원업체 신제품 정보 ▲

BASIC4MCU > 질문게시판

답변 : 아두이노 소스 코드 길이가 너무 길어져서 질문이 있습니다.

페이지 정보

작성자 master 작성일18-12-03 00:31 조회4,104회 댓글0건

본문

 

// DateTime : 2018-12-03 오전 12:35:52
// by Ok-Hyun Park
//
#include <LED.h>
#include "Temperature.h"
#include "Humidity.h"
#include <UltraSonic.h>
#include "Switch.h"
#include "RgbLcd.h"
//
RgbLcd      lcd;
LED         myled;
Humidity    humidity;
#define     TEMP_ADDR  72
#define     HUMI_ADC   55
UltraSonic  dUltra;
Temperature temper;
Switch      pushSwitch;
//
const charhouse[]={
  "        -------------------------------------------------------------------\r\n"//0
  "        |                                                                 |\r\n"//1
  "        |                            veranda                              |\r\n"//2
  "        |                                                                 |\r\n"//3
  "        -------------------------------------------------------------------\r\n"//4
  "        |                 |                                  |            |\r\n"//5
  "        |                 |                                  |            |\r\n"//6
  "        |                 |                                  |            |\r\n"//7
  "        |     room 1      |                                  |    room 2  |\r\n"//8
  "        |                 |                                  |            |\r\n"//9
  "        |                 |                                  |            |\r\n"//10
  "---------------------------                                  --------------\r\n"//11
  "|       |                                                                 |\r\n"//12
  "|   t   |                living room                                      |\r\n"//13
  "|   o   |                                                    -------------|\r\n"//14
  "|   i   |                                                    |            |\r\n"//15
  "|   l   |                                                    |            |\r\n"//16
  "|   e   |                                                    |   room 3   |\r\n"//17
  "|   t   |                                                    |            |\r\n"//18
  "|       |                                                    |            |\r\n"//19
  "|-----------------------------------------           ---------------------|\r\n"//20
  "        |            |                         |           |\r\n"//21
  "        |            |                         |           |\r\n"//22
  "        |    door    |                         |           |\r\n"//23
  "        |            |                         |           |\r\n"//24
  "        |------------|                         |           |\r\n"//25
  "                                  |------------|           |\r\n"//26
  "                                  |                        |\r\n"//27
  "                                  |         kitchen        |\r\n"//28
  "                                  |                        |\r\n"//29
  "                                  |                        |\r\n"//30
  "                                  |------------------------|\r\n"//31
};
//
void tailPrint(){
  Serial3.print("hudi: "); Serial3.print(humidity.read()); Serial3.println("%");
  Serial3.print("temp: "); Serial3.print(temper.getTemperatureC()); Serial3.print("℃");
  Serial3.print("\n\n");
}
//
void blueprint(){
  for(int i=0i<32i++)Serial3.print(house[i]);
  tailPrint();
  Serial3.print("\n\n\n\n\n\n\n\n\n\n\n\r\n");
}
//
void blueprint_door_open(){
  for(int i=0i<24i++)Serial3.print(house[i]);
  Serial3.print("        | (light On) |                         |           |                     \r\n"); //24
  for(int i=25i<32i++)Serial3.print(house[i]);
  tailPrint();
  Serial3.print("light On\n\n\n\n\n\n\n\n\n\n\n\r\n");
}
//
void blueprint_door_close(){
  for(int i=0i<24i++)Serial3.print(house[i]);
  Serial3.print("        | (light Off)|                         |           |                     \r\n"); //24
  for(int i=25i<32i++)Serial3.print(house[i]);
  tailPrint();
  Serial3.print("light Off\n\n\n\n\n\n\n\n\n\n\n\r\n");
}
//
void blueprint_room1_open(){
  for(int i=0i<11i++)Serial3.print(house[i]);
  Serial3.print("----------|    ------------                                  --------------\r\n");
  Serial3.print("|       | |                                                               |\r\n");
  Serial3.print("|   t   | |              living room                                      |\r\n");
  for(int i=14i<32i++)Serial3.print(house[i]);
  tailPrint();
  Serial3.print("light Off\n\n\n\n\n\n\n\n\n\n\n\r\n");
}
//
void blueprint_all_open(){
  for(int i=0i<11i++)Serial3.print(house[i]);
  Serial3.print("----------|    ------------                                  -------   |---\r\n");
  Serial3.print("|       | |                                                            |  |\r\n");
  Serial3.print("|   t   |                living room                               |      |\r\n");
  Serial3.print("|   o   ------                                               ------|   ---|\r\n");
  Serial3.print("|   i                                                        |            |\r\n");
  Serial3.print("|   l                                                        |            |\r\n");
  for(int i=17i<32i++)Serial3.print(house[i]);
  tailPrint();
  Serial3.print("light Off\n\n\n\n\n\n\n\n\n\n\n\r\n");
}
//
void blueprint_room1_2_open(){
  for(int i=0i<11i++)Serial3.print(house[i]);
  Serial3.print("----------|    ------------                                  ------   |----\r\n");
  Serial3.print("|       | |                                                           |   |\r\n");
  Serial3.print("|   t   | |              living room                                      |\r\n");
  for(int i=14i<32i++)Serial3.print(house[i]);
  tailPrint();
  Serial3.print("light Off\n\n\n\n\n\n\n\n\n\n\n\r\n");
}
//
void blueprint_room1_2_toilet_open(){
  for(int i=0i<11i++)Serial3.print(house[i]);
  Serial3.print("----------|    ------------                                  ------   |----\r\n");
  Serial3.print("|       | |                                                           |   |\r\n");
  Serial3.print("|   t   | |              living room                                      |\r\n");
  Serial3.print("|   o   ------                                               -------------|\r\n");
  Serial3.print("|   i                                                        |            |\r\n");
  Serial3.print("|   l                                                        |            |\r\n");
  for(int i=17i<32i++)Serial3.print(house[i]);
  tailPrint();
  Serial3.print("light Off\n\n\n\n\n\n\n\n\n\n\n\r\n");
}
//
void blueprint_room1_toilet_open(){
  for(int i=0i<11i++)Serial3.print(house[i]);
  Serial3.print("----------|    ------------                                  --------------\r\n");
  Serial3.print("|       | |                                                               |\r\n");
  Serial3.print("|   t   | |              living room                                      |\r\n");
  Serial3.print("|   o   -------                                              -------------|\r\n");
  Serial3.print("|   i                                                        |            |\r\n");
  Serial3.print("|   l                                                        |            |\r\n");
  for(int i=17i<32i++)Serial3.print(house[i]);
  tailPrint();
  Serial3.print("light Off\n\n\n\n\n\n\n\n\n\n\n\r\n");
}
//
void blueprint_room1_room3_open(){
  for(int i=0i<11i++)Serial3.print(house[i]);
  Serial3.print("----------|    ------------                                  --------------\r\n");
  Serial3.print("|       | |                                                               |\r\n");
  Serial3.print("|   t   |                living room                                  |   |\r\n");
  Serial3.print("|   o   |                                                    -----    |---|\r\n");
  for(int i=15i<32i++)Serial3.print(house[i]);
  tailPrint();
  Serial3.print("light Off\n\n\n\n\n\n\n\n\n\n\n\r\n");
}
//
void setup(){
  humidity.begin(HUMI_ADC);
  temper.begin(TEMP_ADDR);
  Serial3.begin(115200);
  myled.begin(36);
  dUltra.begin(75,2);
  pushSwitch.begin();
  lcd.begin(62,63,64,65,66,67,45,44,43,42,16,2);
  lcd.onBacklightBlue();
  blueprint();
}
//
void loop(){
  int room1=0,room2=0,room3=0,toilet=0;
  uint8_t pushKey;
  int distance=0;
  distance=dUltra.ReadDistanceCentimeter();
  delay(100);
  //
  if(distance<50){
    myled.AllOn(); blueprint_door_open(); delay(3000);
    myled.AllOff(); blueprint();
  }
  if(pushKey>0){
    if(pushKey==1){
      if(room1==0){
        if     (room2==1&&room3==1&&toilet==1){ blueprint_all_open();            room1=1; }
        else if(room2==1&&room3==0&&toilet==0){ blueprint_room1_2_open();        room1=1; }
        else if(room2==1&&room3==0&&toilet==1){ blueprint_room1_2_toilet_open(); room1=1; }
        else if(room2==0&&room3==1&&toilet==0){ blueprint_room1_room3_open();    room1=1; }
        else if(room2==0&&room3==0&&toilet==1){ blueprint_room1_toilet_open();   room1=1; }
        else if(room2==0&&room3==0&&toilet==0){ blueprint_room1_open();          room1=1; }
      }
      else if(room1==1){
        if(room2==0&&room3==0){ blueprint(); room1=0; }
      }
    }
    else if(pushKey==2){ }
  }
}

 

  • BASIC4MCU 작성글 SNS에 공유하기
  • 페이스북으로 보내기
  • 트위터로 보내기
  • 구글플러스로 보내기
  • 카카오톡으로 보내기

댓글 : 0

조회수 : 4,104

등록된 댓글이 없습니다.

게시물 검색

BASIC4MCU > 질문게시판 목록

제목 날짜
공지 MCU, AVR, 아두이노 등 전자공학에 관련된 질문은… 스태프  19-01-15
공지 사이트 이용 안내 댓글[25] master  17-10-29
질문 아두이노 센서 쉴드 v5.0 과 음성인식 모듈(V2)통… 첨부파일AutoSun 새글 17:58
질문 초음파 센서를 사용한 dc모터 제어에 관해 질문 있습니… 첨부파일뉴비에오 새글 22-07-04
답변 답변 : 초음파 센서를 사용한 dc모터 제어에 관해 질… 댓글[2] master 새글 10:56
질문 아두이노 Sensor Shield 5.0 시리얼 통신 … 댓글[2] AutoSun 새글 22-07-04
질문 Atmega 코드 좀 봐주세요. 댓글[1] 첨부파일chelsea 새글 22-07-04
질문 아두이노 while문 탈출 질문 yhj2644  22-07-01
답변 답변 : 아두이노 while문 탈출 질문 댓글[8] master  22-07-01
질문 ESP32-C3 리튬폴리머 ADC 전압 체크 관련 문의… 댓글[3] cansad  22-06-30
질문 ESP32-C3 리튬폴리머 ADC 전압 체크 관련 문의 댓글[3] cansad  22-06-30
질문 빵판없이 디스플레이 넣을 수 있을까요? 댓글[2] 첨부파일오소로롯  22-06-29
질문 라즈베리파이4 신형 선택문제 댓글[1] maximum  22-06-26
질문 음전압 ADC 댓글[2] 412904  22-06-26
질문 아두이노 센서값 출력 질문입니다! 댓글[1] 아궁2  22-06-24
질문 ATmega128, ATmega28 RS232통신 첨부파일Moon4201  22-06-24
답변 답변 : ATmega128, ATmega28 RS232… 댓글[1] master  22-06-25
질문 서보모터, 온습도센서 코드 질문 댓글[2] 첨부파일kshdlfaldfh  22-06-22
답변 답변 : 서보모터, 온습도센서 코드 질문 댓글[15] master  22-06-22
질문 steppermulti5 질문 응애  22-06-21
답변 답변 : steppermulti5 질문 댓글[1] master  22-06-22
질문 atmega128 avr usart 질문 snoflak  22-06-21
답변 답변 : atmega128 avr usart 질문 댓글[5] master  22-06-21
질문 사용자 정의 함수 변환 하는 방법 댓글[2] 첨부파일da0800  22-06-21
질문 atmega128 댓글[1] 양의노래  22-06-20
질문 아두이노 동시동작 재질문 댓글[9] 첨부파일죠르디  22-06-20
질문 초음파센서로 dc모터 제어하기 댓글[1] 첨부파일난쟁2  22-06-20
질문 아두이노 동시동작 댓글[7] 죠르디  22-06-19
질문 ATMEGA128 UART,FND 연동 질문 JMOD  22-06-19
답변 답변 : ATMEGA128 UART,FND 연동 질문 댓글[1] master  22-06-20
게시물 검색


Privacy Policy
MCU BASIC ⓒ 2017
PC버전