Last active
February 27, 2017 21:04
-
-
Save pyxze/249731cc4325fd8cd4101d46511d0bcb to your computer and use it in GitHub Desktop.
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
// This is for the OSEPP 16x2 Arduino LCD Shield | |
// Also need the library from https://osepp.com/downloads/LCDKeypad.zip | |
// include the library code: | |
#include <LiquidCrystal.h> | |
// initialize the library with the numbers of the interface pins | |
//LiquidCrystal lcd(12, 11, 5, 4, 3, 2); | |
LiquidCrystal lcd(8, 9, 4, 5, 6, 7); | |
String inData; | |
void setup() { | |
lcd.begin(16, 2); | |
Serial.begin(115200); | |
} | |
void loop() { | |
while (Serial.available() > 0) | |
{ | |
char recieved = Serial.read(); | |
inData += recieved; | |
if (recieved == '*') | |
{ | |
inData.remove(inData.length() - 1, 1); | |
lcd.setCursor(0,0); | |
lcd.print(inData); | |
inData = ""; | |
if(inData == "DIS") | |
{ | |
lcd.clear(); | |
lcd.setCursor(0,0); | |
lcd.print("Disconnected!"); | |
} | |
} | |
if (recieved == '#') | |
{ | |
inData.remove(inData.length() - 1, 1); | |
lcd.setCursor(0,1); | |
lcd.print(inData); | |
inData = ""; | |
} | |
} | |
} |
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
# Corresponding Python snippet to show date and time | |
import serial | |
import time | |
import datetime | |
ser = serial.Serial("COM4", 115200) | |
while True: | |
ser.write((datetime.datetime.now().strftime('%x') + "*").encode('ascii')) | |
ser.write((datetime.datetime.now().strftime('%X') + "#").encode('ascii')) | |
time.sleep(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment