Created
November 12, 2019 02:48
-
-
Save jyotendra/560dd5cccb4c35890b74f48ac59062d7 to your computer and use it in GitHub Desktop.
Demonstration of receiving data from arduino via python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int count=0; | |
void setup() | |
{ | |
Serial.begin(9600); | |
} | |
void loop() | |
{ | |
while(1) | |
{ | |
if(count<20) | |
{ | |
Serial.println(count); | |
delay(1000); | |
count=count+1; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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