Created
October 27, 2012 10:01
-
-
Save robertcasanova/3963880 to your computer and use it in GitHub Desktop.
Print IP to LCD
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
| #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; | |
| } | |
| } | |
| } |
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 | |
| 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