SERIAL PORT COMMUNICATION BETWEEN PYTHON AND ARDUINO IN EMBEDDED C

I am a noobie. I have given a project in which I have to send the number of pixels using OpenCV in python to Arduino and to make a led glow based on the number of pixels. How to send data from python to Arduino in embedded c using the serial port communication. Anyone with a code similar to this?

sivaneshtamil:
How to send data from python to Arduino in embedded c

What do you mean by “in embedded c”?

I know how to send data from Python to an Arduino program and Arduino programs are written in C - is that what you mean? have a look at this Python - Arduino demo

…R

Robin2:
What do you mean by "in embedded c"?

I know how to send data from Python to an Arduino program and Arduino programs are written in C - is that what you mean? have a look at this Python - Arduino demo

...R

Embedded c in the sense without using Arduino inbuild functions like serial.read() but by using UART.

sivaneshtamil:
Embedded c in the sense without using Arduino inbuild functions like serial.read() but by using UART.

Why not use the Arduino functions - they make life a lot simpler.

If you want to write your own equivalent of serial.read() and the code beneath it that captures the UART data and puts it into the serial input buffer you will need to study the Atmega 328 datasheet (or whatever Atmel chip you are using).

Why not use the Arduino serial code as a basis for your own code - provided you comply with the licence conditions.

...R

Robin2:
Why not use the Arduino functions - they make life a lot simpler.

If you want to write your own equivalent of serial.read() and the code beneath it that captures the UART data and puts it into the serial input buffer you will need to study the Atmega 328 datasheet (or whatever Atmel chip you are using).

Why not use the Arduino serial code as a basis for your own code - provided you comply with the licence conditions.

...R

But my project is that I should use only embedded c coding. :frowning:

sivaneshtamil:
But my project is that I should use only embedded c coding. :frowning:

That is why I wrote what I did in the second paragraph of Reply #3

If you have a more specific meaning or scope for "embedded c" then you need to explain it.

,,,R

But my project is that I should use only embedded c coding.

Then quit wasting our time, and get on with your project. There is already a perfectly good way to read serial data on the Arduino.

Since you have rejected that way, YOU can figure out ON YOUR OWN how to not use the perfectly good way.