- In the extension bar, click the AdBlock Plus icon
- Click the large blue toggle for this website
- Click refresh
- In the extension bar, click the AdBlock icon
- Under "Pause on this site" click "Always"
- In the extension bar, click on the Adguard icon
- Click on the large green toggle for this website
- In the extension bar, click on the Ad Remover icon
- Click "Disable on This Website"
- In the extension bar, click on the orange lion icon
- Click the toggle on the top right, shifting from "Up" to "Down"
- In the extension bar, click on the Ghostery icon
- Click the "Anti-Tracking" shield so it says "Off"
- Click the "Ad-Blocking" stop sign so it says "Off"
- Refresh the page
- In the extension bar, click on the uBlock Origin icon
- Click on the big, blue power button
- Refresh the page
- In the extension bar, click on the uBlock icon
- Click on the big, blue power button
- Refresh the page
- In the extension bar, click on the UltraBlock icon
- Check the "Disable UltraBlock" checkbox
- Please disable your Ad Blocker
- Disable any DNS blocking tools such as AdGuardDNS or NextDNS
- Disable any privacy or tracking protection extensions such as Firefox Enhanced Tracking Protection or DuckDuckGo Privacy.
If the prompt is still appearing, please disable any tools or services you are using that block internet ads (e.g. DNS Servers, tracking protection or privacy extensions).
Question
tarifa
Hi, there at all good day dear community
I'm trying to create a communicate betwheen Arduino and my PC> The host-pc runs on windows. At the moment my code is just very simple: What is aimed: i just want to switch on a LED when i send data from the host to the Arduino: But this is actually not working. i struggle a bit with this piece of code.
By the way: i make use of pySerial.
Findings: when i try to send the data to from the host (in other words the pc )to my arduino the led TX blinks but the part of my code which is right behind the if ( serial.available()>0) doesn't run at all - i am pulling my hair.
Here is tbe full code: i begin with the Python part
import serial serie=serial.Serial() serie.baudrate=9600 serie.port= 'COM4' serie.parity=serial.PARITY_ODD serie.stopbits=serial.STOPBITS_ONE serie.bytesize=serial.EIGHTBITS if serie.isOpen(): serie.close() serie.open() serie.isOpen() serie.write("hello".encode
and here we have the Arduino code:
int ledPin = 9; byte incomingByte; void setup() { Serial.begin(9600); pinMode(ledPin, OUTPUT); } void loop() { if (Serial.available() > 0) { incomingByte = Serial.read(); digitalWrite(ledPin, HIGH); } delay(1000); digitalWrite(ledPin, LOW);}
well - i tried to look at a full python sample code that uses pyserial, i have the package and am wondering how to send the commands and read them back!
again: what is aimed: Use the Arduino ide to turn the Arduino LED on and off.
import time import serial # configure the serial connections (the parameters differs on the device you are connecting to) ser = serial.Serial( port='/dev/ttyUSB1', baudrate=9600, parity=serial.PARITY_ODD, stopbits=serial.STOPBITS_TWO, bytesize=serial.SEVENBITS ) ser.isOpen() print 'Enter your commands below.\r\nInsert "exit" to leave the application.' input=1 while 1 : # get keyboard input input = raw_input(">> ") # Python 3 users # input = input(">> ") if input == 'exit': ser.close() exit() else: # send the character to the device # (note that I happend a \r\n carriage return and line feed to the characters - this is requested by my device) ser.write(input + '\r\n') out = '' # let's wait one second before reading output (let's give device time to answer) time.sleep(1) while ser.inWaiting() > 0: out += ser.read(1) if out != '': print ">>" + out
what i have taken from the Arduino-specs;
- i think that the usage of "PARITY_ODD? does not help here - since Arduino does not handle PARITY.
- guess that i have to try it with PARITY_NONE.
and subsequently: most Arduinos reset when we open the serial port of them. That will give us a certain delay of a few seconds during which time the Arduino can not receive data from your PC (and it will be lost).
so i have to deal with this time somehow!!?
above all: i sure have to do some tests and have to learn to use the referenced Arduino code and how to use pyserial.
Dear community - i do some tests and will try to digg deeper in that sort of problems.
above all: i am so glad to be here at this great place of idea-sharing and knowledge-exchange. : to be here at this place is just great - and a overwehelming experience to me.
plz - keep up this great place - it is one of the best places for all programming and internet things i ever have experienced
i love this forum!!!!
keep up the great project - it rocks!!
Link to comment
https://www.neowin.net/forum/topic/1388930-data-exchange-between-arduino-pc-fails-making-clear-to-use-pyserail-correct/Share on other sites
0 answers to this question
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now