Advertisement
Guest User

ArduinoLab3

a guest
Oct 16th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.14 KB | None | 0 0
  1. void setup() {
  2.   // put your setup code here, to run once:
  3.   Serial.begin(19200, SERIAL_8E1);
  4.   Serial.println("ASCII Table - Character Map");
  5. }
  6.  
  7. int thisByte = 'U';
  8.  
  9. void loop() {
  10.   // put your main code here, to run repeatedly:
  11.   Serial.write(thisByte);
  12.   delay(1000);
  13. }
  14.  
  15. #include <SoftwareSerial.h>
  16.  
  17. Software mySerial(2, 3); //pin2 -> RX, pin3-> TX
  18.  
  19. int newLineSerial=true;
  20.  
  21. void setup(){
  22.     //Open Serial communications and wait for port to open:
  23.     Serial.begin(57600);
  24.     Serial.println("Hardware UART Up!);
  25.  
  26.     //Configure the data rate for the SW UART
  27.     mySerial.begin(4800); //8 Data Bit, No Parity, 1 STOP Bit
  28. }
  29.  
  30. void loop(){
  31.     if(Serial.available())
  32.     {
  33.         if(newLineSerial) //If Newline character received
  34.         {
  35.             mySerial.write("PCI>> ");
  36.             newLineSerial=false;
  37.         }
  38.         else
  39.         {
  40.             int byteRead = Serial.read();   //read from HW UART (Data from PC's Serial monitor)
  41.             mySerial.write(byteRead); //Write to SW UART, which is connected to the SW UART on the other Arduino Board
  42.             if(byteRead=='\n') newLineSerial=true;
  43.         }
  44.     }
  45.  
  46.     if(mySerial.available())
  47.     {
  48.         Serial.write(mySerial.read()); //Output to Serial Monitor
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement