Python Code to move the actuator Forward and Backward code not working - please help

Below is the python program which i am trying to move the actuator forward and backward.

Devices used :

  1. Arduino Uno
  2. Actuator : Carviya 2 Pack Universal Car Auto Heavy Duty Power Door Lock Actuator Motor Professional 2 Wires DC 12V Auto Central Locking System Motor
  3. L298N

I want to move the actuator forward and backward or push and pull using below code. But no luck as of now. Can somebody please help.

import serial

import time

ser = serial.Serial('COM6', 9600)

time.sleep(2)

if ser.isOpen():

print("Port Open")

ser.write(b'10')

time.sleep(5)

ser.close()

Even though the Arduino IDE makes extensive use of Python, the main language spoken here is C++. Try a Python site.

C and C++ code works absolutely fine.

If you have any python references, i can explore.

Thanks for the quick reply.

Please define not working.

  1. Is that the complete Python code?
  2. A wild guess ( :slight_smile: ) is that you use an Arduino; which one? Where is the code for it?
  3. You are aware that most Arduinos reboot when you open te serial port?

Please spend some time reading https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum/679966; one of the things that it explains is how to use code tags when posting code; please apply it when posting code again, thanks.

I use the Raspberry Pi site for my Python questions.

Another recourse is to type words into an internet search engine. The words I use relate to the subject.

Words like "arduino python communications."

This Arduino Code moves the actuator absolutely fine.

void setup() {
pinMode(10, OUTPUT); // Configure pin 7 as an Output
pinMode(9, OUTPUT); // Configure pin 8 as an Output

digitalWrite(10, HIGH);
digitalWrite(9, HIGH);

delay(500);
digitalWrite(10, LOW);
digitalWrite(9, HIGH);
delay(500);
digitalWrite(10, LOW);
digitalWrite(9, HIGH);
delay(500);
digitalWrite(10, HIGH);
digitalWrite(9, HIGH);
delay(500);
digitalWrite(10, HIGH);
digitalWrite(9, LOW);

}

void loop() {
}

But i am trying to convert this to python and do the same action as my other code is in python.

tried using pyserial, pyfirmata but no luck.

Kindly help if you know any other source of converting the above code to python.

Write code for you? I want a 10,000.00USD non-refundable deposit of good faith and I charge 250.00USD per hour billable in 4 hour increments.

So where does an Arduino fit in? Can you please give a proper description of your project?

Here is some reading that might help you (based on original your opening post)

  1. Serial Input Basics - updated
  2. Demo of PC-Arduino comms using Python

Thankyou for sharing this. I will explore. This really helps.

As far as I know, you cannot use Python to program an Uno. Adafruit offers some micro controllers that use CircuitPython.