Error: INSERT INTO `kin_1_104` (subject, seo_subject, content, page, description, og_image, time) VALUES ('아두이노 nextion 질문드립니다 ㅜㅜ', '%EC%95%84%EB%91%90%EC%9D%B4%EB%85%B8+nextion+%EC%A7%88%EB%AC%B8%EB%93%9C%EB%A6%BD%EB%8B%88%EB%8B%A4+%E3%85%9C%E3%85%9C', '
\n \n \n

코딩 질문드립니다. 코드를 만들었는데 아래의 코드에서 두 가지 문제점이 발생합니다.

\n

\n

1. 스위치 on은 작동되지만 스위치 off가 작동되지 않습니다.

\n

(스위치 ON을 하면 압력센서출력, LCD, 부저 LED 다 켜집니다. 스위치를 다시 눌렀을 때 모두 다 꺼지게 하고 싶습니다)

\n

2. 부저가 delay(100)으로 울리게 하고 싶은데 계속 울리고 있습니다...

\n

\n

나머지 LCD,LED,압력센서는 잘되는데 부저와 스위치 문제 전혀 모르겠습니다 ㅜㅜ

\n

\n

아두이노 나노 사용중이고 NEXTION LCD 사용중입니다.

\n

----------------------------------------------------------------------------------------------------------------------------------

\n

\n

#include <MsTimer2.h>

\n

#include <FastLED.h>

\n

#include <Nextion.h>

\n

\n

#define LED_PIN 5 // arduino nano digital 5 = led pin

\n

#define NUM_LEDS 3 // LED 갯수 3개

\n

\n

#define FSR_PIN A2 // arduino nano analoge 2 = FSR

\n

\n

#define BUZZER_PIN 11 // arduino nano digital 11 = buzzer

\n

\n

#define SWITCH_ON A0 // arduino nano analoge 0 = switch

\n

\n

/* --------------------nano 설정-------------------- */

\n

\n

int FSR_Read; // FSR A0 pin

\n

int FSR_Max = 0;

\n

\n

int timer2_cnt;

\n

int button_cnt=0;

\n

int buzzer_cnt=0;

\n

\n

int switch_value;

\n

int switch_on_flag = 0;

\n

int old_switch_on_flag = 0;

\n

\n

CRGB leds[NUM_LEDS]; // LED 갯수

\n

\n

/* --------------------LCD 설정-------------------- */

\n

\n

int FSR_Read_Perc = 0; // progressbar 표시

\n

\n

char buffer[100] = {0}; // for lcd text

\n

\n

SoftwareSerial HMISerial(1, 2); // arduino nano RX/TX interupt

\n

\n

NexButton button1 = NexButton(0, 1, \"button1\"); // page0 male

\n

NexButton button2 = NexButton(0, 2, \"button2\"); // page0 female

\n

NexButton button3 = NexButton(0, 3, \"button3\"); // page0 old

\n

NexButton button4 = NexButton(3, 1, \"button4\"); // page3 back

\n

NexButton button5 = NexButton(3, 2, \"button5\"); // page3 male

\n

NexButton button6 = NexButton(3, 3, \"button6\"); // page3 female

\n

NexButton button7 = NexButton(1, 1, \"button7\"); // page1 back

\n

NexButton button8 = NexButton(2, 1, \"button8\"); // page2 back

\n

NexButton button9 = NexButton(4, 1, \"button9\"); // page4 back

\n

NexButton button10 = NexButton(5, 1, \"button10\"); // page5 back

\n

\n

NexText txt1 = NexText(0, 4, \"txt1\"); // page0 CPRWIZARD

\n

\n

NexProgressBar j1 = NexProgressBar(1, 2, \"j1\"); // page1 prograssbar

\n

NexProgressBar j2 = NexProgressBar(2, 2, \"j2\"); // page2 prograssbar

\n

NexProgressBar j3 = NexProgressBar(4, 2, \"j3\"); // page4 prograssbar

\n

NexProgressBar j4 = NexProgressBar(5, 2, \"j4\"); // page5 prograssbar

\n

\n

NexText n1 = NexText(1, 3, \"n1\"); // page1 num

\n

NexText n2 = NexText(2, 3, \"n2\"); // page2 num

\n

NexText n3 = NexText(4, 3, \"n3\"); // page3 num

\n

NexText n4 = NexText(5, 3, \"n4\"); // page4 num

\n

\n

// 화면에 터치를 하는 것들 touch event list에 등록

\n

NexTouch *nex_event_list[] = {

\n

&button1, &button2, &button3, &button4, &button5,

\n

&button6, &button7, &button8, &button9, &button10, NULL

\n

};

\n

\n

\n

\n

/* --------------------nano 설정-------------------- */

\n

\n

void timer2_int() // switch button & buzzer 설정

\n

{

\n

timer2_cnt++;

\n

\n

if(button_cnt < 15)

\n

{

\n

button_cnt++;

\n

}

\n

\n

if(buzzer_cnt >0)

\n

{

\n

buzzer_cnt--;

\n

}

\n

}

\n

\n

void switch_option_check() // switch button 설정

\n

{

\n

switch_value = analogRead(SWITCH_ON);

\n

\n

\n

if(switch_value < 50)

\n

{

\n

if(switch_on_flag==0)

\n

{

\n

switch_on_flag = 1;

\n

buzzer_cnt=10;

\n

buzzer_on();

\n

button_cnt =0;

\n

}

\n

else

\n

{

\n

if(button_cnt > 10)

\n

{

\n

switch_on_flag = 0;

\n

old_switch_on_flag = 0;

\n

\n

digitalWrite(BUZZER_PIN, LOW);

\n

}

\n

}

\n

}

\n

}

\n

\n

void buzzer_on() // buzzer on

\n

{

\n

digitalWrite(BUZZER_PIN, HIGH);

\n

}

\n

\n

void buzzer_off() // buzzer off

\n

{

\n

digitalWrite(BUZZER_PIN, LOW);

\n

}

\n

\n

void read_FSR(void)

\n

{

\n

int flag = 0;

\n

if(flag == 0)

\n

{

\n

FSR_Max = 0;

\n

for(int i=0 ; i< 500 ; ++i)

\n

{

\n

FSR_Read = analogRead(FSR_PIN);

\n

if(FSR_Read >= FSR_Max)

\n

{

\n

FSR_Max = FSR_Read;

\n

flag = 1;

\n

}

\n

}

\n

}

\n

\n

if(flag == 1)

\n

{

\n

flag = 0;

\n

}

\n

}

\n

\n

\n

/* --------------------LCD 설정-------------------- */

\n

\n

void button3_Callback(void *ptr) // 혹시 모르는 Call Back 설정

\n

{

\n

FSR_Read = analogRead(FSR_PIN);

\n

if(FSR_Read) {return;}

\n

\n

char h_FSR_Read[10] = {0};

\n

utoa(int(FSR_Read), h_FSR_Read, 10);

\n

// txt5.setText(h_FSR_Read);

\n

\n

}

\n

\n

void page_1(void) // page1 설정

\n

{

\n

FSR_Read_Perc = (FSR_Max / 10);

\n

j1.setValue(FSR_Read_Perc);

\n

\n

n1.setText(buffer);

\n

memset(buffer, 0, sizeof(buffer));

\n

itoa(FSR_Max, buffer, 10);

\n

}

\n

\n

void page_2(void) // page2 설정

\n

{

\n

FSR_Read_Perc = (FSR_Max / 10);

\n

j2.setValue(FSR_Read_Perc);

\n

\n

n2.setText(buffer);

\n

memset(buffer, 0, sizeof(buffer));

\n

itoa(FSR_Max, buffer, 10);

\n

}

\n

\n

void page_3(void) // page3 설정

\n

{

\n

FSR_Read_Perc = (FSR_Max / 10);

\n

j3.setValue(FSR_Read_Perc);

\n

\n

n3.setText(buffer);

\n

memset(buffer, 0, sizeof(buffer));

\n

itoa(FSR_Max, buffer, 10);

\n

}

\n

\n

void page_4(void) // page4 설정

\n

{

\n

FSR_Read_Perc = (FSR_Max / 10);

\n

j4.setValue(FSR_Read_Perc);

\n

\n

n4.setText(buffer);

\n

memset(buffer, 0, sizeof(buffer));

\n

itoa(FSR_Max, buffer, 10);

\n

}

\n

\n

\n

void setup()

\n

{

\n

/* --------------------nano 설정-------------------- */

\n

\n

Serial.begin(9600);

\n

\n

pinMode(SWITCH_ON, INPUT);

\n

pinMode(BUZZER_PIN, OUTPUT);

\n

\n

digitalWrite(BUZZER_PIN, LOW);

\n

\n

FastLED.addLeds<WS2812, LED_PIN, GRB> (leds, NUM_LEDS);

\n

\n

MsTimer2::set(10, timer2_int); // 50ms timer

\n

MsTimer2::start();

\n

\n

/* --------------------LCD 설정-------------------- */

\n

nexInit(); // nextion 초기화

\n

pinMode(FSR_PIN, INPUT);

\n

\n

}

\n

\n

\n

\n

\n

\n

void loop()

\n

{

\n

switch_option_check();

\n

\n

if(switch_on_flag==1)

\n

{

\n

if(buzzer_cnt > 8)

\n

{

\n

buzzer_on();

\n

}

\n

else if(buzzer_cnt == 0)

\n

{

\n

buzzer_cnt = 10;

\n

buzzer_on();

\n

}

\n

else

\n

{

\n

buzzer_off();

\n

}

\n

\n

\n

read_FSR(); // 외부함수 FSR 불러오기

\n

\n

page_1(); // LCD page1 불러오기

\n

page_2(); // LCD page2 불러오기

\n

page_3(); // LCD page3 불러오기

\n

page_4(); // LCD page4 불러오기

\n

\n

nexLoop(nex_event_list); // nextion에서 발생하는 이벤트를 라이브러리로 전달

\n

\n

if(FSR_Max > 1 && FSR_Max <= 500)

\n

{

\n

leds[0] = CRGB (0, 0 ,0);

\n

leds[1] = CRGB (0 ,0 ,0);

\n

leds[2] = CRGB (0 ,0 ,0);

\n

FastLED.show();

\n

}

\n

else if(FSR_Max > 500 && FSR_Max <=600)

\n

{

\n

leds[0] = CRGB (15, 10 ,0);

\n

leds[1] = CRGB (15 ,10 ,0);

\n

leds[2] = CRGB (15 ,10 ,0);

\n

FastLED.show();

\n

}

\n

else if(FSR_Max > 600 && FSR_Max <= 850)

\n

{

\n

leds[0] = CRGB (0 ,10 ,0);

\n

leds[1] = CRGB (0 ,10 ,0);

\n

leds[2] = CRGB (0 ,10 ,0);

\n

FastLED.show();

\n

}

\n

else if(FSR_Max > 850)

\n

{

\n

leds[0] = CRGB (10 ,0 ,0);

\n

leds[1] = CRGB (10 ,0 ,0);

\n

leds[2] = CRGB (10 ,0 ,0);

\n

FastLED.show();

\n

}

\n

\n

Serial.print(\"FSR_Read \");

\n

Serial.println(FSR_Read);

\n

Serial.print(\"FSR_Max \");

\n

Serial.println(FSR_Max);

\n

}

\n

delay(100);

\n

}

\n

\n

----------------------------------------------------------------------------------------------------------------------------------

\n \n\n \n \n \n \n\n \n \n\n \n \n \n
', '1_104_421112944', ' 코딩 질문드립니다. 코드를 만들었는데 아래의 코드에서 두 가지 문제점이 발생합니다. ​ 1. 스위치 on은 작동되지만 스위치 off가 작동되지 않습니다. (스위치 ON을 하면 압력센서출력, LCD, 부저 LED 다 켜집니다. 스위치를 다시 눌렀을 때 모두 다 꺼지게 하고 싶습니다) 2. 부저가 delay(100)으로 울리게 하고 싶은데 계속 울리고 있습니다... ​ 나머지 LCD,LED,압력센서는 잘되는데 부저와 스위치 문제 전혀 모르겠습니다 ㅜㅜ ​ 아두이노 나노 사용중이고 NEXTION LCD 사용중입니다. ---------------------------------------------------------------------------------------------------------------------------------- ​ #include <MsTimer2.h> #include <FastLED.h> #include <Nextion.h> ​ #define LED_PIN 5 // arduino nano digital 5 = led pin #define NUM_LEDS 3 // LED 갯수 3개 ​ #define FSR_PIN A2 // arduino nano analoge 2 = FSR ​ #define BUZZER_PIN 11 // arduino nano digital 11 = buzzer ​ #define SWITCH_ON A0 // arduino nano analoge 0 = switch ​ /* --------------------nano 설정-------------------- */ ​ int FSR_Read; // FSR A0 pin int FSR_Max = 0; ​ int timer2_cnt; int button_cnt=0; int buzzer_cnt=0; ​ int switch_value; int switch_on_flag = 0; int old_switch_on_flag = 0; ​ CRGB leds[NUM_LEDS]; // LED 갯수 ​ /* --------------------LCD 설정-------------------- */ ​ int FSR_Read_Perc = 0; // progressbar 표시 ​ char buffer[100] = {0}; // for lcd text ​ SoftwareSerial HMISerial(1, 2); // arduino nano RX/TX interupt ​ NexButton button1 = NexButton(0, 1, \"button1\"); // page0 male NexButton button2 = NexButton(0, 2, \"button2\"); // page0 female NexButton button3 = NexButton(0, 3, \"button3\"); // page0 old NexButton button4 = NexButton(3, 1, \"button4\"); // page3 back NexButton button5 = NexButton(3, 2, \"button5\"); // page3 male NexButton button6 = NexButton(3, 3, \"button6\"); // page3 female NexButton button7 = NexButton(1, 1, \"button7\"); // page1 back NexButton button8 = NexButton(2, 1, \"button8\"); // page2 back NexButton button9 = NexButton(4, 1, \"button9\"); // page4 back NexButton button10 = NexButton(5, 1, \"button10\"); // page5 back ​ NexText txt1 = NexText(0, 4, \"txt1\"); // page0 CPRWIZARD ​ NexProgressBar j1 = NexProgressBar(1, 2, \"j1\"); // page1 prograssbar NexProgressBar j2 = NexProgressBar(2, 2, \"j2\"); // page2 prograssbar NexProgressBar j3 = NexProgressBar(4, 2, \"j3\"); // page4 prograssbar NexProgressBar j4 = NexProgressBar(5, 2, \"j4\"); // page5 prograssbar ​ NexText n1 = NexText(1, 3, \"n1\"); // page1 num NexText n2 = NexText(2, 3, \"n2\"); // page2 num NexText n3 = NexText(4, 3, \"n3\"); // page3 num NexText n4 = NexText(5, 3, \"n4\"); // page4 num ​ // 화면에 터치를 하는 것들 touch event list에 등록 NexTouch *nex_event_list[] = { &button1, &button2, &button3, &button4, &button5, &button6, &button7, &button8, &button9, &button10, NULL }; ​ ​ ​ /* --------------------nano 설정-------------------- */ ​ void timer2_int() // switch button & buzzer 설정 { timer2_cnt++; ​ if(button_cnt < 15) { button_cnt++; } ​ if(buzzer_cnt >0) { buzzer_cnt--; } } ​ void switch_option_check() // switch button 설정 { switch_value = analogRead(SWITCH_ON); ​ ​ if(switch_value < 50) { if(switch_on_flag==0) { switch_on_flag = 1; buzzer_cnt=10; buzzer_on(); button_cnt =0; } else { if(button_cnt > 10) { switch_on_flag = 0; old_switch_on_flag = 0; ​ digitalWrite(BUZZER_PIN, LOW); } } } } ​ void buzzer_on() // buzzer on { digitalWrite(BUZZER_PIN, HIGH); } ​ void buzzer_off() // buzzer off { digitalWrite(BUZZER_PIN, LOW); } ​ void read_FSR(void) { int flag = 0; if(flag == 0) { FSR_Max = 0; for(int i=0 ; i< 500 ; ++i) { FSR_Read = analogRead(FSR_PIN); if(FSR_Read >= FSR_Max) { FSR_Max = FSR_Read; flag = 1; } } } ​ if(flag == 1) { flag = 0; } } ​ ​ /* --------------------LCD 설정-------------------- */ ​ void button3_Callback(void *ptr) // 혹시 모르는 Call Back 설정 { FSR_Read = analogRead(FSR_PIN); if(FSR_Read) {return;} ​ char h_FSR_Read[10] = {0}; utoa(int(FSR_Read), h_FSR_Read, 10); // txt5.setText(h_FSR_Read); ​ } ​ void page_1(void) // page1 설정 { FSR_Read_Perc = (FSR_Max / 10); j1.setValue(FSR_Read_Perc); ​ n1.setText(buffer); memset(buffer, 0, sizeof(buffer)); itoa(FSR_Max, buffer, 10); } ​ void page_2(void) // page2 설정 { FSR_Read_Perc = (FSR_Max / 10); j2.setValue(FSR_Read_Perc); ​ n2.setText(buffer); memset(buffer, 0, sizeof(buffer)); itoa(FSR_Max, buffer, 10); } ​ void page_3(void) // page3 설정 { FSR_Read_Perc = (FSR_Max / 10); j3.setValue(FSR_Read_Perc); ​ n3.setText(buffer); memset(buffer, 0, sizeof(buffer)); itoa(FSR_Max, buffer, 10); } ​ void page_4(void) // page4 설정 { FSR_Read_Perc = (FSR_Max / 10); j4.setValue(FSR_Read_Perc); ​ n4.setText(buffer); memset(buffer, 0, sizeof(buffer)); itoa(FSR_Max, buffer, 10); } ​ ​ void setup() { /* --------------------nano 설정-------------------- */ ​ Serial.begin(9600); ​ pinMode(SWITCH_ON, INPUT); pinMode(BUZZER_PIN, OUTPUT); ​ digitalWrite(BUZZER_PIN, LOW); ​ FastLED.addLeds<WS2812, LED_PIN, GRB> (leds, NUM_LEDS); ​ MsTimer2::set(10, timer2_int); // 50ms timer MsTimer2::start(); ​ /* --------------------LCD 설정-------------------- */ nexInit(); // nextion 초기화 pinMode(FSR_PIN, INPUT); ​ } ​ ​ ​ ​ ​ void loop() { switch_option_check(); ​ if(switch_on_flag==1) { if(buzzer_cnt > 8) { buzzer_on(); } else if(buzzer_cnt == 0) { buzzer_cnt = 10; buzzer_on(); } else { buzzer_off(); } ​ ​ read_FSR(); // 외부함수 FSR 불러오기 ​ page_1(); // LCD page1 불러오기 page_2(); // LCD page2 불러오기 page_3(); // LCD page3 불러오기 page_4(); // LCD page4 불러오기 ​ nexLoop(nex_event_list); // nextion에서 발생하는 이벤트를 라이브러리로 전달 ​ if(FSR_Max > 1 && FSR_Max <= 500) { leds[0] = CRGB (0, 0 ,0); leds[1] = CRGB (0 ,0 ,0); leds[2] = CRGB (0 ,0 ,0); FastLED.show(); } else if(FSR_Max > 500 && FSR_Max <=600) { leds[0] = CRGB (15, 10 ,0); leds[1] = CRGB (15 ,10 ,0); leds[2] = CRGB (15 ,10 ,0); FastLED.show(); } else if(FSR_Max > 600 && FSR_Max <= 850) { leds[0] = CRGB (0 ,10 ,0); leds[1] = CRGB (0 ,10 ,0); leds[2] = CRGB (0 ,10 ,0); FastLED.show(); } else if(FSR_Max > 850) { leds[0] = CRGB (10 ,0 ,0); leds[1] = CRGB (10 ,0 ,0); leds[2] = CRGB (10 ,0 ,0); FastLED.show(); } ​ Serial.print(\"FSR_Read \"); Serial.println(FSR_Read); Serial.print(\"FSR_Max \"); Serial.println(FSR_Max); } delay(100); } ​ ---------------------------------------------------------------------------------------------------------------------------------- ', 'https://cboard.net/sitemap/og_image.php?text=아두이노 nextion 질문드립니다 ㅜㅜ&link=https://cboard.net/k/1_104_421112944', '2022.06.06')
Data too long for column 'content' at row 1 아두이노 nextion 질문드립니다 ㅜㅜ

아두이노 nextion 질문드립니다 ㅜㅜ

아두이노 nextion 질문드립니다 ㅜㅜ

작성일 2022.06.06댓글 0건
    게시물 수정 , 삭제는 로그인 필요

코딩 질문드립니다. 코드를 만들었는데 아래의 코드에서 두 가지 문제점이 발생합니다.

1. 스위치 on은 작동되지만 스위치 off가 작동되지 않습니다.

(스위치 ON을 하면 압력센서출력, LCD, 부저 LED 다 켜집니다. 스위치를 다시 눌렀을 때 모두 다 꺼지게 하고 싶습니다)

2. 부저가 delay(100)으로 울리게 하고 싶은데 계속 울리고 있습니다...

나머지 LCD,LED,압력센서는 잘되는데 부저와 스위치 문제 전혀 모르겠습니다 ㅜㅜ

아두이노 나노 사용중이고 NEXTION LCD 사용중입니다.

----------------------------------------------------------------------------------------------------------------------------------

#include <MsTimer2.h>

#include <FastLED.h>

#include <Nextion.h>

#define LED_PIN 5 // arduino nano digital 5 = led pin

#define NUM_LEDS 3 // LED 갯수 3개

#define FSR_PIN A2 // arduino nano analoge 2 = FSR

#define BUZZER_PIN 11 // arduino nano digital 11 = buzzer

#define SWITCH_ON A0 // arduino nano analoge 0 = switch

/* --------------------nano 설정-------------------- */

int FSR_Read; // FSR A0 pin

int FSR_Max = 0;

int timer2_cnt;

int button_cnt=0;

int buzzer_cnt=0;

int switch_value;

int switch_on_flag = 0;

int old_switch_on_flag = 0;

CRGB leds[NUM_LEDS]; // LED 갯수

/* --------------------LCD 설정-------------------- */

int FSR_Read_Perc = 0; // progressbar 표시

char buffer[100] = {0}; // for lcd text

SoftwareSerial HMISerial(1, 2); // arduino nano RX/TX interupt

NexButton button1 = NexButton(0, 1, "button1"); // page0 male

NexButton button2 = NexButton(0, 2, "button2"); // page0 female

NexButton button3 = NexButton(0, 3, "button3"); // page0 old

NexButton button4 = NexButton(3, 1, "button4"); // page3 back

NexButton button5 = NexButton(3, 2, "button5"); // page3 male

NexButton button6 = NexButton(3, 3, "button6"); // page3 female

NexButton button7 = NexButton(1, 1, "button7"); // page1 back

NexButton button8 = NexButton(2, 1, "button8"); // page2 back

NexButton button9 = NexButton(4, 1, "button9"); // page4 back

NexButton button10 = NexButton(5, 1, "button10"); // page5 back

NexText txt1 = NexText(0, 4, "txt1"); // page0 CPRWIZARD

NexProgressBar j1 = NexProgressBar(1, 2, "j1"); // page1 prograssbar

NexProgressBar j2 = NexProgressBar(2, 2, "j2"); // page2 prograssbar

NexProgressBar j3 = NexProgressBar(4, 2, "j3"); // page4 prograssbar

NexProgressBar j4 = NexProgressBar(5, 2, "j4"); // page5 prograssbar

NexText n1 = NexText(1, 3, "n1"); // page1 num

NexText n2 = NexText(2, 3, "n2"); // page2 num

NexText n3 = NexText(4, 3, "n3"); // page3 num

NexText n4 = NexText(5, 3, "n4"); // page4 num

// 화면에 터치를 하는 것들 touch event list에 등록

NexTouch *nex_event_list[] = {

&button1, &button2, &button3, &button4, &button5,

&button6, &button7, &button8, &button9, &button10, NULL

};

/* --------------------nano 설정-------------------- */

void timer2_int() // switch button & buzzer 설정

{

timer2_cnt++;

if(button_cnt < 15)

{

button_cnt++;

}

if(buzzer_cnt >0)

{

buzzer_cnt--;

}

}

void switch_option_check() // switch button 설정

{

switch_value = analogRead(SWITCH_ON);

if(switch_value < 50)

{

if(switch_on_flag==0)

{

switch_on_flag = 1;

buzzer_cnt=10;

buzzer_on();

button_cnt =0;

}

else

{

if(button_cnt > 10)

{

switch_on_flag = 0;

old_switch_on_flag = 0;

digitalWrite(BUZZER_PIN, LOW);

}

}

}

}

void buzzer_on() // buzzer on

{

digitalWrite(BUZZER_PIN, HIGH);

}

void buzzer_off() // buzzer off

{

digitalWrite(BUZZER_PIN, LOW);

}

void read_FSR(void)

{

int flag = 0;

if(flag == 0)

{

FSR_Max = 0;

for(int i=0 ; i< 500 ; ++i)

{

FSR_Read = analogRead(FSR_PIN);

if(FSR_Read >= FSR_Max)

{

FSR_Max = FSR_Read;

flag = 1;

}

}

}

if(flag == 1)

{

flag = 0;

}

}

/* --------------------LCD 설정-------------------- */

void button3_Callback(void *ptr) // 혹시 모르는 Call Back 설정

{

FSR_Read = analogRead(FSR_PIN);

if(FSR_Read) {return;}

char h_FSR_Read[10] = {0};

utoa(int(FSR_Read), h_FSR_Read, 10);

// txt5.setText(h_FSR_Read);

}

void page_1(void) // page1 설정

{

FSR_Read_Perc = (FSR_Max / 10);

j1.setValue(FSR_Read_Perc);

n1.setText(buffer);

memset(buffer, 0, sizeof(buffer));

itoa(FSR_Max, buffer, 10);

}

void page_2(void) // page2 설정

{

FSR_Read_Perc = (FSR_Max / 10);

j2.setValue(FSR_Read_Perc);

n2.setText(buffer);

memset(buffer, 0, sizeof(buffer));

itoa(FSR_Max, buffer, 10);

}

void page_3(void) // page3 설정

{

FSR_Read_Perc = (FSR_Max / 10);

j3.setValue(FSR_Read_Perc);

n3.setText(buffer);

memset(buffer, 0, sizeof(buffer));

itoa(FSR_Max, buffer, 10);

}

void page_4(void) // page4 설정

{

FSR_Read_Perc = (FSR_Max / 10);

j4.setValue(FSR_Read_Perc);

n4.setText(buffer);

memset(buffer, 0, sizeof(buffer));

itoa(FSR_Max, buffer, 10);

}

void setup()

{

/* --------------------nano 설정-------------------- */

Serial.begin(9600);

pinMode(SWITCH_ON, INPUT);

pinMode(BUZZER_PIN, OUTPUT);

digitalWrite(BUZZER_PIN, LOW);

FastLED.addLeds<WS2812, LED_PIN, GRB> (leds, NUM_LEDS);

MsTimer2::set(10, timer2_int); // 50ms timer

MsTimer2::start();

/* --------------------LCD 설정-------------------- */

nexInit(); // nextion 초기화

pinMode(FSR_PIN, INPUT);

}

void loop()

{

switch_option_check();

if(switch_on_flag==1)

{

if(buzzer_cnt > 8)

{

buzzer_on();

}

else if(buzzer_cnt == 0)

{

buzzer_cnt = 10;

buzzer_on();

}

else

{

buzzer_off();

}

read_FSR(); // 외부함수 FSR 불러오기

page_1(); // LCD page1 불러오기

page_2(); // LCD page2 불러오기

page_3(); // LCD page3 불러오기

page_4(); // LCD page4 불러오기

nexLoop(nex_event_list); // nextion에서 발생하는 이벤트를 라이브러리로 전달

if(FSR_Max > 1 && FSR_Max <= 500)

{

leds[0] = CRGB (0, 0 ,0);

leds[1] = CRGB (0 ,0 ,0);

leds[2] = CRGB (0 ,0 ,0);

FastLED.show();

}

else if(FSR_Max > 500 && FSR_Max <=600)

{

leds[0] = CRGB (15, 10 ,0);

leds[1] = CRGB (15 ,10 ,0);

leds[2] = CRGB (15 ,10 ,0);

FastLED.show();

}

else if(FSR_Max > 600 && FSR_Max <= 850)

{

leds[0] = CRGB (0 ,10 ,0);

leds[1] = CRGB (0 ,10 ,0);

leds[2] = CRGB (0 ,10 ,0);

FastLED.show();

}

else if(FSR_Max > 850)

{

leds[0] = CRGB (10 ,0 ,0);

leds[1] = CRGB (10 ,0 ,0);

leds[2] = CRGB (10 ,0 ,0);

FastLED.show();

}

Serial.print("FSR_Read ");

Serial.println(FSR_Read);

Serial.print("FSR_Max ");

Serial.println(FSR_Max);

}

delay(100);

}

----------------------------------------------------------------------------------------------------------------------------------


#아두이노 nextion #nextion 아두이노 통신 #nextion hmi lcd 아두이노

아두이노 질문드립니다.

... nextion HMI는 사용해 보지 않아 모르니 질문의 코드를 활용했습니다. #include <Nextion.h> #include <SoftwareSerial.h> #define PIN_SENS A0...

아두이노 질문드립니다ㅜㅜ

1.아두이노 동작 감지센서 어떤게 있을까요?(인체감지 말고 물체감지) 2.제가... 내공 100드립니다 ㅜㅜ 초음파 혹은 적외선 거리센서를 사용해보세요. 원하시는 내용인지는...

아두이노 전자회로 질문합니다ㅜ

... 아두이노의 3.3V 핀으로 한 회로에 전원을 공급하고, 5V 핀으로 다른 회로에 전원을... 1번 2번 정말 모르겠어서 질문 드립니다ㅜㅜ 1. 첫 번째 회로에는 220 옴 저항이...

아두이노 센서값 질문드립니다.

#include <Nextion.h> #include <SoftwareSerial.h> char... t1.setText(strDtostr); } 디스플레이 nextion사용... https://www.itead.cc/blog/nextion-tutorial-based-on...