// Looking at serial on the scope
// Trace 1 shows a 300 baud 8N1 serial line slowly counting through
// a 0x00-0xff progression, triggered on the falling edge of the start bit
// Trace 2 shows the state of the LED_BUILTIN blink at the time of the serial send
// trace 3 shows the serial communications to the terminal
/*
Uno with Scope https://github.com/Dlloydev/Wokwi-Chip-Scope
and https://github.com/Dlloydev/Wokwi-Chip-PWM
and https://github.com/drf5n/Wokwi-Chip-FrequencyCounter
Wokwi Uno https://wokwi.com/projects/390819301187622913
Wokwi Nano https://wokwi.com/projects/426440872904255489
Wokwi Mega: https://wokwi.com/projects/390819455604080641
Wokwi ESP32: https://wokwi.com/projects/408508221519641601
Wokwi ESP32S3 https://wokwi.com/projects/404720144387009537
See also https://wokwi.com/projects/359331973918199809
*/
/*
Running Blink.ino
Turns an LED on for one second, then off for one second, repeatedly.
Most Arduinos have an on-board LED you can control. On the UNO, MEGA and ZERO
it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN is set to
the correct LED pin independent of which board is used.
If you want to know what pin the on-board LED is connected to on your Arduino
model, check the Technical Specs of your board at:
https://docs.arduino.cc/hardware/
modified 8 May 2014
by Scott Fitzgerald
modified 2 Sep 2016
by Arturo Guadalupi
modified 8 Sep 2016
by Colby Newman
This example code is in the public domain.
https://docs.arduino.cc/built-in-examples/basics/Blink/
*/
#include <SoftwareSerial.h>
//#include <SoftwareSerialTX.h>
const byte RX1=3;
const byte TX1=2;
const long MyBaud=300;
const long DelayMs = 100;
const uint8_t MaxReps= 0;
SoftwareSerial mySerial(RX1,TX1); // RX, TX
//SoftwareSerialTX mySerial(TX1); // TX
// the setup function runs once when you press reset or power the board
void setup() {
Serial.begin(9600);
mySerial.begin(MyBaud);
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
pinMode(TX1, OUTPUT);
Serial.print("BitTime:");
Serial.print(1000.00/MyBaud,4);
Serial.print("ms");
Serial.print(" ByteTime:");
Serial.print(1000.00*9/MyBaud,4);
Serial.println("ms");
}
uint8_t ch =-3;
uint8_t rep =0;
// the loop function runs over and over again forever
void loop() {
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(2); // wait for a second
mySerial.write(ch);
if(true || !isPrintable(ch)){
//Serial.write(ch);
Serial.print("0x");
Serial.print(ch,HEX);
} else {
Serial.print(ch);
Serial.print(char(ch));
}
Serial.print(",");
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
if(rep-- == 0 ){
ch+=1;
rep = MaxReps;
}
if(ch==0)Serial.println();
delay(DelayMs); // wait for a second
}Wokwi UnoScope
https://wokwi.com/projects/390819301187622913
https://wokwi.com/projects/475333106739257345 Serial