Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SoftwareSerial.h>
- int RX_PIN = 2;
- int TX_PIN = 3;
- int BAUD_IDE = 9600;
- int BAUD_WEIGHT_SENSOR = 9600;
- String serialData = "";
- SoftwareSerial mySerial = SoftwareSerial(RX_PIN, TX_PIN);
- void setup()
- {
- mySerial.begin(BAUD_WEIGHT_SENSOR);
- Serial.begin(BAUD_IDE);
- }
- void loop()
- {
- while (mySerial.available())
- {
- int inChar = mySerial.read();
- if (inChar != '\n')
- {
- serialData += (char)inChar;
- }
- else
- {
- int dataSize = serialData.length();
- Serial.print(serialData); Serial.print(" length: ");
- Serial.print(dataSize); Serial.print("\n");
- delay(3000);
- serialData = "";
- }
- } serialData = "";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement