Advertisement
Kevin_Zhang

Untitled

Jun 8th, 2020
362
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.88 KB | None | 0 0
  1. /**
  2.  * Displays text sent over the serial port (e.g. from the Serial Monitor) on
  3.  * an attached LCD.
  4. #include <Wire.h>
  5. #include <LiquidCrystal_I2C.h>
  6.  */
  7. #include <SoftwareSerial.h>   // 引用程式庫
  8.  
  9. SoftwareSerial BT(9,8); // RX | TX
  10. const int val = 0, L_motor = 4, R_motor = 6, Monitor_val = 38400, Bt_speed = 9600;
  11. void setup() {
  12.     Serial.begin(Monitor_val);
  13.     Serial.println("Arduino Nano Ready");
  14.  
  15.     BT.begin(Bt_speed);
  16.     pinMode(L_motor,OUTPUT);
  17.     pinMode(R_motor,OUTPUT);
  18. }
  19. // Set the LCD address to 0x27 for a 16 chars and 2 line display
  20. // LiquidCrystal_I2C lcd(0x27, 16, 2);
  21. int getint() {
  22.     static int p;
  23.     int x = 0;
  24.     while (!BT.available() || isdigit(p = BT.read()))
  25.         x = x * 10 + p;
  26.     return x;
  27. }
  28. String getstring(char sep = '\n') {
  29.     static char p;
  30.     String x;
  31.     while (!BT.available() || (p = BT.read()) != sep)
  32.         x += p;
  33.     return x;
  34. }
  35. void loop() {
  36.  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement