hi dears i have a file named numbers in my desktop. that have numbers such:
1
2
3
4
5
6
i want read and send this file line to line to Arduino by Python.
import serial
import time
Arduino = serial.Serial(port='COM7', 9600, timeout=.1)
file = open('file')
while 1:
line = file.line()
if not line:
break
time.sleep(10)
now i want in Arduino if the number be from 1 to 3 the my motor DC rotate in clockwise three seconds.
and if the number be 3 to 6 the motor rotate in anticlockwise three seconds.
my circuit dc motor
i have no problem in Python and know the code to change direction in Arduino as below:
void setup() {
pin(_PIN, OUTPUT);
pin(IN1_PIN, OUTPUT);
pin(IN2_PIN, OUTPUT);
}
void loop() {
rite(IN1_PIN, HIGH);
rite(IN2_PIN, LOW);
delay(10);
}
delay(1000);
digital(IN1_PIN, LOW);
digital(IN2_PIN, HIGH);
and know a little about serial event in Arduino that is to capture data coming from python.
but my main problem is that i do not know how to puzzle all above codes to do my goal turn on my dc motor.
thanks dears to guiding me
i try tutorial for dc motor in Arduino site.
and want to use of numbers in my csv file to turn dc motor and change direction.
isa davoud is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.