Can you help me?

//include libraries
#include <SoftwareSerial.h>

//include sensor ultrasonic
#define ECHOPIN 12
#define TRIGPIN 11
int H2,HT,H1;

SoftwareSerial mySerial(0, 1);

void setup() {
mySerial.begin(9600);
pinMode(ECHOPIN, INPUT);
pinMode(TRIGPIN, OUTPUT);
delay(1000);
HT=200;
}

void loop() {
delay(2000);
digitalWrite(TRIGPIN, LOW);
delayMicroseconds(2);
digitalWrite(TRIGPIN, HIGH);
delayMicroseconds(10);
digitalWrite(TRIGPIN, LOW);
int distance = pulseIn(ECHOPIN, HIGH);
distance = distance/58;
H2 = HT-distance;
mySerial.print("t0.txt="");
mySerial.print(H2);
mySerial.print(""");
/Serial.print("nTinggi.val=5");
Serial.print(H2);
Serial.print(""");
/
mySerial.write(0xff);
mySerial.write(0xff);
mySerial.write(0xff);
delay(1000);
/*

  • When a pop or push event occured every time,
  • the corresponding component[right page id and component id] in touch event list will be asked.
    nexLoop(nex_listen_list);/
    }

before that, I'm sorry if my language is difficult to understand. I'm still learning. :sob:
and, sorry if it does not comply with the rules of the post on this forum. I'm noob :cry: :cry:

THX

If I understand your code correctly, It seems that you using RX and TX hardware pins with software serial library with Arduino UNO? That is not allowed. Simply use hardware Serial as shown in basic examples inside Arduino software IDE, or use digital pin 2 or 3 (or other suitable) with software serial library.

As far is concerned to me, do not apologize by the language, to many people here English is not native. Just be clear what is the problem, what Arduino/MCU is and make short subject describing the problem/question, instead "Can you help me". As well use code tags when posting code.

THX

i used arduino uno and in board, RX pin 0 & TX pin 1..
i too change a NexConfig.h for compatible in arduino uno, is it wrong??

so, what should i do??

noob314:
If I understand your code correctly, It seems that you using RX and TX hardware pins with software serial library with Arduino UNO? That is not allowed. Simply use hardware Serial as shown in basic examples inside Arduino software IDE, or use digital pin 2 or 3 (or other suitable) with software serial library.

As far is concerned to me, do not apologize by the language, to many people here English is not native. Just be clear what is the problem, what Arduino/MCU is and make short subject describing the problem/question, instead "Can you help me". As well use code tags when posting code.

There's no point using a software UART when there's a perfectly good hardware one.

This isn't really an installation issue.

Connect whatever is connected to pins 0 and 1 to e.g. pins 2 and 3 and modify your sketch to use those pins for software serial.

I have no idea what you did regarding NexConfig.h. Avoid to change any system files after Arduino installation, unless you are certain that will not be harmful or change some functionality. Reinstall clean Arduino software again.

You can do one of two things I already suggested you. If you do any of these, UART code will work.

i have tried, but still can`t work

noob314:
I have no idea what you did regarding NexConfig.h. Avoid to change any system files after Arduino installation, unless you are certain that will not be harmful or change some functionality. Reinstall clean Arduino software again.

You can do one of two things I already suggested you. If you do any of these, UART code will work.

  1. Open Arduino IDE
  2. Go to menu: File -> Examples -> 01 Basic -> AnalogReadSerial
  3. Compile and upload
  4. Go to "Serial Monitor", ensure it is set 9600 baud

You need to see some output, otherwise there is some problem I'm unable to help you without more details.

i have tried, then ?
sorry, what is the function to try that?

noob314:

  1. Open Arduino IDE
  2. Go to menu: File -> Examples -> 01 Basic -> AnalogReadSerial
  3. Compile and upload
  4. Go to "Serial Monitor", ensure it is set 9600 baud

You need to see some output, otherwise there is some problem I'm unable to help you without more details.

You have to confirm me do you see output on Serial Monitor when compile and upload this example. If you do, your Arduino software and hardware works fine with UART.

Then change your code according to this example and that is all.

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html .
Then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Can I suggest you look for the NewPing library and let it do ALL the hardwork of driving the ultrasonic unit?

What model Arduino are you using?

Thanks.. Tom... :slight_smile:

circuit ? or my code ?
i use Arduino Uno

TomGeorge:
Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html .
Then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Can I suggest you look for the NewPing library and let it do ALL the hardwork of driving the ultrasonic unit?

What model Arduino are you using?

Thanks.. Tom... :slight_smile:

It is indeed difficult to give you any help if you do not follow suggestions.
Do you know how to activate "Serial Monitor" in Arduino IDE?

This is your code I have modified for hardware serial. Try it.

//include libraries
//#include <SoftwareSerial.h>

//include sensor ultrasonic
#define ECHOPIN 12                           
#define TRIGPIN 11
int H2,HT,H1;

//SoftwareSerial mySerial(0, 1);

void setup() {
Serial.begin(9600);
pinMode(ECHOPIN, INPUT);
pinMode(TRIGPIN, OUTPUT);
delay(1000);
HT=200;
}

void loop() {
  delay(2000);
  digitalWrite(TRIGPIN, LOW);                   
  delayMicroseconds(2);
  digitalWrite(TRIGPIN, HIGH);                 
  delayMicroseconds(10);
  digitalWrite(TRIGPIN, LOW);                   
  int distance = pulseIn(ECHOPIN, HIGH);
  distance = distance/58;
  H2 = HT-distance;
  Serial.print("t0.txt=\"");
  Serial.print(H2);
  Serial.print("\"");
  /*Serial.print("nTinggi.val=5");
  Serial.print(H2);
  Serial.print("\"");*/
  Serial.write(0xff);
  Serial.write(0xff);
  Serial.write(0xff);
  delay(1000);
  /*
   * When a pop or push event occured every time,
   * the corresponding component[right page id and component id] in touch event list will be asked.
   *nexLoop(nex_listen_list);*/
}

THX...
apparently this is very unique.

we assume pins Rx = 0, Tx = 1, then

  • if we want to upload, then the pin remains nothing is changed. but

  • if we want to test nextion, then the pins must be exchanged. Rx = 1, Tx = 0.

and it works ..
THX again, for your help

noob314:
It is indeed difficult to give you any help if you do not follow suggestions.
Do you know how to activate "Serial Monitor" in Arduino IDE?

This is your code I have modified for hardware serial. Try it.

//include libraries

//#include <SoftwareSerial.h>

//include sensor ultrasonic
#define ECHOPIN 12                         
#define TRIGPIN 11
int H2,HT,H1;

//SoftwareSerial mySerial(0, 1);

void setup() {
Serial.begin(9600);
pinMode(ECHOPIN, INPUT);
pinMode(TRIGPIN, OUTPUT);
delay(1000);
HT=200;
}

void loop() {
  delay(2000);
  digitalWrite(TRIGPIN, LOW);                 
  delayMicroseconds(2);
  digitalWrite(TRIGPIN, HIGH);               
  delayMicroseconds(10);
  digitalWrite(TRIGPIN, LOW);                 
  int distance = pulseIn(ECHOPIN, HIGH);
  distance = distance/58;
  H2 = HT-distance;
  Serial.print("t0.txt="");
  Serial.print(H2);
  Serial.print(""");
  /Serial.print("nTinggi.val=5");
  Serial.print(H2);
  Serial.print(""");
/
  Serial.write(0xff);
  Serial.write(0xff);
  Serial.write(0xff);
  delay(1000);
  /*
  * When a pop or push event occured every time,
  * the corresponding component[right page id and component id] in touch event list will be asked.
  nexLoop(nex_listen_list);/
}