简体   繁体   中英

How do I send commands to Arduino over serial from a .sh file?

I am working on a project where I am using a Raspberry Pi and an Arduino together via USB. On the Arduino, I have my code setup to where I send it a letter over serial and it will do something (for example, if I send 'A' over serial, it will turn on a LED. B will turn it off, etc.). I have already tested all of the commands with the serial monitor, so I know my Arduino code works. On the Raspberry Pi, I want to be able to run a .sh file and have it send a letter over serial to the Arduino. In trying to do this, I have looked at many forums (including the one here: http://playground.arduino.cc/Interfacing/LinuxTTY ) and every time I try to send something, the lights on the Arduino flash and it basically produces the same result as pressing the reset button. So, how do I write a .sh file to send commands to my Arduino? Thank you in advance! -Ethan

I believe there is a difference in the voltages used on the ardino (5V) vs the raspberry pi (3.3V), so you cant just directly connected them up.

Instead, you need to use a voltage divider/converter so that is has the correct voltages.

This is explained in detail at this website: https://oscarliang.com/raspberry-pi-and-arduino-connected-serial-gpio/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM