I am new to the forums/Arduino so if I have any problems creating this thread or anything else let me know.
I am trying to read in data serially from the RX port, then Transmit data using that received data. I currently use the functions Serial.read for the receiving and Serial.write for the Serial transmission. The problem I am having is when I scoped the output from the TX port, it is a curved waveform.
It basically looks like one positive decaying exponential and one negative decaying exponential. They are symmetric across the y and x axis'. The picture is not mine, but it looks similar to this.
I have scoped the input, and scoured the data sheet and such with no avail, any help would be much appreciated!
I would prefer to stick to UART, it works better with my system. Also I have tried powering through DC and USB to no avail. I am using an actual Arduino Zero not a clone or genuino or MO.
So here is my code. I have a signal coming in at around 3 V to the RX port then a line just like Paul Stoffregen's for probing. Thanks for the replies, I think my problem may lie in the syntax. I am very green when it comes to some of this so I apologize if I am missing something very small. I appreciate any insights given and the time invested in solving this problem.
void loop() {
if (Serial.available() > 0) {
// read the incoming byte:
Received = Serial.read();
}
if (Received == 24) {
Serial.begin(2400);
}
if (Received == 48) {
Serial.begin(4800);
}
if (Received == 16) {
Serial1.write(Received);
}
if (Received == 32) {
Serial1.write(Received);
}
if (Received == 64) {
Serial1.write(Received);
}
You're trying to send the number "16" to the Serial port? You should use ascii character :
16 (decimal) is the character 'DLE', a special command. 48 decimal is the character '&' etc... (look on google for ascii table). So if you send "16" through the Serial port, it a 2 bytes message : the ascii code of '1' (= 49) and then the ascii code of '6' (=54).
#include <arduino.h>
int Vselect1 = 9;
int Vselect2 = 10;
int Mux1_1 = 11;
int Mux1_2 = 12; //Intialize Vselect1 to pin 9, and Vselect2 to pin 10.
int Received = 0;
void setup() {
pinMode (Vselect1, OUTPUT); //set the select lines as output
pinMode (Vselect2, OUTPUT);
pinMode (Mux1_1, OUTPUT);
Serial1.begin(4800); //Open the Serial port with 2400 Baud rate default
}
void loop() {
if (Serial1.available() > 0) {
Received = Serial1.read();
}
Serial1.write(Received);
analogWrite(Vselect1, 32); //Write the waveform at 100% to the select lines
analogWrite(Vselect2,64);
analogWrite(Mux1_1, 128);
}
This currently works for what I need it to do, which is basically write the Received values straight to the Transmit port. The IF statements along with the Received variable were having a tough time but now just straight writing the Received variable works.
Thanks for the suggestions!
Daniel
Thanks for the suggestions!
If you want to process command coming from the serial port, you can check the Serial examples (Bottom right corner). Especially the ReadASCIIString one.