Skip to content

Instantly share code, notes, and snippets.

@jyotendra
Created November 12, 2019 02:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jyotendra/560dd5cccb4c35890b74f48ac59062d7 to your computer and use it in GitHub Desktop.
Save jyotendra/560dd5cccb4c35890b74f48ac59062d7 to your computer and use it in GitHub Desktop.
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