How to send commands without typing it on the serial monitor?

Hi, I'm newb to arduino.

I'm using arduino to communicate with FPGA so that if I type special command on the serial monitor, FPGA will make the corresponding output. It occurs without any specific arduino code.

(i.e. I have to type "0100" on the arduino serial monitor to make FPGA have output of "1011", something like that)

What I want to do is to make the command automatically sent to the arduino board via serial monitor using loop.
So far, I couldn't figure out any other way of sending data without typing...
Could you please give me some advice on this?


Your post was MOVED to its current location as it is more suitable.

Please post the code that you are using at the moment following the advice in How to get the best out of this forum regarding the use of code tags

how are arduino/fpga connected? presumably not via Serial1?

Hi! @gcjr

I'm not the one who designed the system so not 100 percent sure,
but I think Arduino and fpga are connected by default serial because the code I upload on the arduino is opening default serial (by just calling Serial.begin(baudrate).

If you mean serial 1 = defult serial, then yes.
Does this answer your question?

how can you communicate with the Arduino via the PC using the "Serial" interface if the "Serial" interface is connected to the FPGA ?

posting your code (using "</>") would help

Oh, I think I got your question wrong. I think they are then connected by physical means, that inputs/outputs are all connected to FPGA by wires (embeded in the large board).

btw, I really don't think this code would help anything, but still upload.
I'm just using arduino as serial communicator & ADC.

int adc = 0;
int ADC_0,ADC_1;

void setup() {
  ADC->ADC_MR |= 0x80; // Mode FREERUN
  ADC->ADC_CR = 2; // Start converter
  ADC->ADC_CHER = 0xFF; // Enabling channels

void loop() {
  if((PIOC -> PIO_PDSR & 0b00000000100000000000000000000000)>>23 == HIGH){
  ADC_0 = ADC->ADC_CDR[7];// read data on A0
  ADC_1 = ADC->ADC_CDR[6];// read data on A1

  Serial.print("ADC0 Value =");
  Serial.print(ADC_0 / 4 );
  Serial.print(", ADC1 Value =");
  Serial.print(ADC_1 / 4);


the posted code doesn't read the serial monitor and i don't believe it shows any output that could possibly be to the FPGA

Well, but that is how my board works...

How about changing my question into this:

Would there be a way of sending string data directly to the port without using serial monitor?

i don't see where that's done in the code unless it's those prints (e.g. "ADC0 Value = ") which are already occurring


I want to send data string without using typing it on the serial monitor.
Would there be any way of doing this?
For example, if I entered "a" on the serial monitor,
string command "1001" should be sent to the port automatically as if I'm entering it on the serial monitor and pressing send button.

Thank you.

Using the IDE's serial monitor, I don't think so. It's possible that a more full featured terminal program might have some Macro expansion features, check a few of them out.

Alternatively, you can write your own program on your PC in you language of choice that talks to the Arduino over Serial and then you can build a custom interface that sends whatever you like.

Hi @wildbill,

Alternatively, you can write your own program on your PC in you language of choice that talks to the Arduino over Serial and then you can build a custom interface that sends whatever you like.

Do you mean something like PySerial using python?
Actually, I have been trying to use it, but I confronted some weird problem there.

Whenever I do serial.write() (which a function for sending data), nothing occurs. But the expected output comes out when I turn on the serial monitor on IDE...

Here is some of my code of python using pyserial:

import pandas as pd
import serial
import time

arduino = serial.Serial(port='/dev/cu.usbmodem14101', baudrate=115200, timeout=10,write_timeout=10)

if arduino.isOpen():
  #this is function for sending data 
    print("1st input done")

    a = arduino.readline().decode().strip()
    if "me too" in a :

in Arduino, I programmed it to print "me too" when it receives "hello" string.
So the thing is, whenever I run this code on python, always this code ends up printing "failed".
But when I turn on the serial monitor from IDE, suddenly "me too" word pops up from the serial monitor.

you're cross posting

Hi, I think I should delete the post you mentioned since it's confusing. Thanks for pointing this out!

Can't you do the translation in the Arduino? Send and receive an "a" but use "1001" or whatever.

Hi @sionaggutraidh
Could you be more specific? What do you mean by translation in the Arduino?

Just some kind of if statement perhaps, if an a is received, make the string to be used = 1001. If what arrives is a b, string to be used = 1100 or whatever.




Could you take a few moments to Learn How To Use The Forum.

Other general help and troubleshooting advice can be found here.
It will help you get the best out of the forum.

I think I could do that, but how can you send that string (ie "1001") back to serial monitor?
I don't need this to be printed on the serial monitor at all, but just to be sent to the serial port.