Hi guys, please help me.
I expect blinking.
This code works good:
void setup() {
pinMode(9, OUTPUT);
}
void loop() {
digitalWrite(9, HIGH);
delay(1000);
digitalWrite(9, LOW);
delay(1000);
}
but with python pyserial doesn't work:
I have problem on:
print ArduinoSerial.readline()
(code is freezing)
so it look's like I can't read data from arduino.
But PORT is correct - I am sure. When I start to run script I see on arduiono board that it receives data.(It is blinking during a second)
OS MAC.
Python 2.7:
import serial
import time
ArduinoSerial = serial.Serial("/dev/cu.wchusbserial1410", 9600)
time.sleep(2)
print ArduinoSerial.readline()
print ("Enter 1 to turn ON LED and 0 to turn OFF LED")
while 1:
var = raw_input() # get input from user
print "you entered", var # print the intput for confirmation
if (var == '1'): # if the value is 1
ArduinoSerial.write('1') # send 1
print ("LED turned ON")
time.sleep(3)
if (var == '0'): # if the value is 0
ArduinoSerial.write('0') # send 0
print ("LED turned OFF")
time.sleep(3)