Skip to content

Instantly share code, notes, and snippets.

@robertcasanova
Created October 27, 2012 10:01
Show Gist options
  • Select an option

  • Save robertcasanova/3963880 to your computer and use it in GitHub Desktop.

Select an option

Save robertcasanova/3963880 to your computer and use it in GitHub Desktop.
Print IP to LCD
#include <LiquidCrystal.h>
String buffer;
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
boolean isPacket = false;
void setup() {
Serial.begin(9600);
lcd.begin(20, 2);
}
void onMessageRecive( String msg) {
lcd.clear();
lcd.print(msg);
}
void loop() {
if(Serial.available()) {
char c = (char) Serial.read();
if(c == '{') {
isPacket = true;
} else if(c == '}') {
isPacket = false;
onMessageRecive(buffer);
buffer = ""; //empty the buffer
} else if(isPacket){
buffer += c;
}
}
}
import serial
import socket
arduino = serial.Serial('/dev/ttyAMA0')
ip = socket.gethostbyname(socket.gethostname())
arduino.write("{IP:"+ip+"}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment