Created
          October 26, 2020 12:20 
        
      - 
      
 - 
        
Save mthri/77cc6bd946c1b451affe518eae44c3c2 to your computer and use it in GitHub Desktop.  
    PySerial Arduino 
  
        
  
    
      This file contains hidden or 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 | |
| ser = serial.Serial('/dev/ttyACM0', baudrate=9600, timeout=1) | |
| data = ser.readline() | |
| data = str(data, encoding='utf-8') | |
| data = data.strip() | |
| ser.close() | |
| ser.open() | |
| ser.write(b'1') | 
  
    
      This file contains hidden or 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
    
  
  
    
  | void setup() { | |
| Serial.begin(9600); | |
| pinMode(LED_BUILTIN, OUTPUT); | |
| } | |
| void loop() { | |
| if(Serial.available()){ | |
| char Command = Serial.read(); | |
| if(Command == '1') | |
| digitalWrite(LED_BUILTIN, HIGH); | |
| else | |
| digitalWrite(LED_BUILTIN, LOW); | |
| } | |
| } | 
  
    
      This file contains hidden or 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
    
  
  
    
  | void setup() { | |
| Serial.begin(9600); | |
| } | |
| void loop() { | |
| Serial.println("Hello From Arduino"); | |
| delay(1000); | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment