Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Demonstration of receiving data from arduino via python
int count=0;
void setup()
{
Serial.begin(9600);
}
void loop()
{
while(1)
{
if(count<20)
{
Serial.println(count);
delay(1000);
count=count+1;
}
}
}
import serial #Serial imported for Serial communication
import time #Required to use delay functions
ArduinoSerial = serial.Serial('com3',9600) #Create Serial port object called arduinoSerialData
time.sleep(2) #wait for 2 secounds for the communication to get established
while(1):
print (ArduinoSerial.readline())#read the serial data and print it as line
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment