+ 3
Arduino serial port working principle??
how a serial port works to get input
5 ответов
+ 3
You have ti define,
BAUD RATE(speed in bits per second)
DATA BITS (length of the char in bits commonly 8)
PARITY BIT(an additional bit to do a primitive error checking: according to how is defined, it changes in order to make the number of 1's in the data bits even or odd )
STOP BIT(additional bit/s used to signal the end of the charachter stream)
FLOW CONTROL(handshaking protocol to stop/resume data stream according to the need of the devices)
Once these parameters are defined the data stream of data is sent as electric pulses for 1 and 0V for 0 timed according to the baud rate.
The standard is 8/N/1: meaning 8 Data Bits/No parity/1 stop bit.
DATA BITS-PARITY- STOP BIT
00000000-(NONE)-0
the data received is stored in a buffer waiting to be read.
Buffer overloading can adversely affect communication: that's where flow control is coming handy.
it can be achieved by hardware using RTS/CTS or DTR/DSR signals
or by software, definig a standard protocol of data exchange requests.
+ 3
Sorry reading again your post I realized my previous answer is too generic.
Arduino is simple:
Communication works the same but a nice built in library takes care of the nitty-gritty.
only define the baud rate in setup by:
void setup(){
Serial.begin(9600); //speed may vary
}
//in the loop read for data, if available in the buffer
void loop(){
while (Serial.available()){
char inData = Serial.read();
//....do here your stuff with the incoming data
Serial.println(inData); //echoing the data back
//echoing is for debugging purpose
}//while loop ends when the serial buffer is empty
}
+ 2
thankyou 😊😊
+ 1
USB serial are the cheap and most useful.
It just collect data from the Arduino pins that you have declared as input (mainly a sensor or button)and then sent it your computer via CP2102 or CH340 etc. (any USB ttl converter) Originally Arduino uses (16u2) and then you computer receives that data at a particular speed known as "baud rate" usually set for 9600 but they could be change according to the need it depends how much faster you need your data to reach you.You can also assign some GUI to it that will respond according your data it can be done by using mother of Arduino ide known as processing ide.You can create projects like a Radar using ultrasonic sensor (HC-SR04)
Best of luck with this
+ 1
thankyou dear @Alfayez