0

I currently have a camera I am trying to run off an Arduino. I am new to Arduino and I have had trouble figuring out what serial and myserial really do. I also don't understand why, when I have something like serial.write(0x56) I will get the output in the serial monitor to be V in hex, but If I have the Arduino also connected to an oscilloscope, I won't be able to see the signal.

Yet if I have myserial.write(0x56), I won't see anything in the serial monitor, but will see the bits on my oscilloscope.

Also, if I send a command to my camera, my camera should send back some hex values if the write command is sent. I understand I can send commands via myserial.write(0x56), but how would I read the hex values the camera would send back?

1

It seems like you are using both the hardware UART pins and two other pins for SoftwareSerial i.e. UART emulated by the arduino.

When you write Serial.read() or Serial.write(), Arduino knows to use the UART hardware on the chip which is has RX/TX pins 0 and 1 for most Arduinos. So by using these functions you will be able to communicate with any device which is connected on these pins.

Generally, when you have the Arduino connected to your computer, these RX/TX pins internally go to a serial port on your computer via the USB, hence you can send/receive data to the computer and view it on the Serial Monitor. Great for debugging purposes!

Sometimes, like in your case for controlling the camera, you need to have another serial port for communication because UART is point to point i.e. only 2 devices can communicate via it. SoftwareSerial helps you do that by using two other pins on the Arduino into RX/TX pins. If you look at the top of your code file you will see a line like this

SoftwareSerial mySerial = SoftwareSerial(...);

Inside the brackets you will also see the two pin numbers which are being used as RX/TX. In the software serial example pins 10,11 are being used. So whatever is connected to these pins (i think your camera module is) will be able to send/receive data using mySerial.write() and mySerial.read().

Hence, to be able to receive data from the camera you will use mySerial.read().

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.