I have an Arduino which I have coded to read from a USB serial port and power an LED.
I know it is working because it works on the built serial monitor. Now I want to write a Bash script which writes to the serial port.
Here is the command:
echo 121 > /dev/cu.usbmodem411
It outputs the string “123”. How can I instead write a single byte with a value of 121?
will write four bytes: 0x31 (meaning ‘1’), 0x32 (meaning ‘2’), 0x31 again, 0x0A (meaning a newline).
If your goal is to write a single byte, with value 121, you would write this:
where 171 is 121 expressed in base-8, and
-ntellsechonot to print a newline character.If that’s not your goal, then please clarify.