How to make Arduino read txt file on PC

Hello, I have a question and I hope I can find an answer here.

Is it possible to make a project in Arduino software to read a txt file on PC?

I am trying to use Image Recognition to unlock a door.

Here is what I did: 1. I have a python program that do "Image Recognition". (DONE) 2. After the Image Recognition (Python) program runs, a txt file called (file.txt) will be crated with only one line of words (AuthorizedPerson) or (UnauthorizedPerson) (DONE)

  1. What I want to do is creating a variable (In Arduino Project) and assign it to the content of the txt file, so if the variable = AuthorizedPerson, then a special RF signal will be sent to unlock the door.

I do know how to send the RF signal, but I don't know how to make Arduino read txt file and assign the content of it to a variable.

Any idea?

The Arduino can't read a text file on the PC, you would need a program on the PC to read it for you and then send it over serial to the Arduino.

Since you already have a python program involved, forget the file and just send the Arduino a message over serial to tell it what to do. The Arduino can parse the text received and act accordingly.

wildbill: The Arduino can't read a text file on the PC, you would need a program on the PC to read it for you and then send it over serial to the Arduino.

Since you already have a python program involved, forget the file and just send the Arduino a message over serial to tell it what to do. The Arduino can parse the text received and act accordingly.

So just to make sure I understand what you said correctly. You want me to send data directly from python to arduino with no need of creating a file to read from it. am I correct?

then I need to do some search to know how to do that.

That's correct.

Search for Python serial arduino. Or search this site for Python serial and Robin2. IIRC, he has posted examples.

This is the Python - Arduino demo. I looked at it recently and it seems a bit dated now compared with the more recent Serial Input Basics

I am in the process of updating the Python demo, but I don't reckon I will have it finished for a few days.

...R

wildbill: That's correct.

Search for Python serial arduino. Or search this site for Python serial and Robin2. IIRC, he has posted examples.

After some search I finally did it. So thank you so much.

Now I can unlock my door using face recognition program (in Python.) Now moving to a new problem, every time I want to unlock the door, I need to run my python program by my self. So the question is, is there a way to make python program runs automatically through Arduino?

For example:

if Serial.read() = 1, run python program

I know that I can write some commands in Terminal to run python Program, but can I send commands from Arduino to Terminal?

This is the updated Arduino - Python example.

...R