Skip to content

Instantly share code, notes, and snippets.

@haider00727
Created February 1, 2023 17:01
Show Gist options
  • Save haider00727/e52a7bea497f626a6ef6d8cf4cedc75a to your computer and use it in GitHub Desktop.
Save haider00727/e52a7bea497f626a6ef6d8cf4cedc75a to your computer and use it in GitHub Desktop.
Dry Run - kiwinan788
#include <LiquidCrystal_I2C.h>
int lcdColumns = 16;
int lcdRows = 2;
LiquidCrystal_I2C lcd(0x27, lcdColumns, lcdRows);
String InBytes;
void setup() {
Serial.begin(9600);
pinMode(4, OUTPUT);
lcd.init();
lcd.backlight();
}
void loop() {
if (Serial.available() > 0) {
InBytes = Serial.readStringUntil('\n');
if (InBytes == "GREEN") {
Serial.write("I GOT GREEN");
}
if (InBytes == "YELLOW") {
Serial.write("I GOT YELLOW");
}
if (InBytes == "RED") {
Serial.write("I GOT RED");
}
else {
Serial.write("BAD INPUT");
}
lcd.setCursor(0, 0);
lcd.print("TRAFIC LIGHT STATUS");
delay(500);
lcd.clear();
lcd.setCursor(0,1);
lcd.print(InBytes);
delay(500);
lcd.clear();
}
}
import serial
import time
serialcomm = serial.Serial('', 9600)
serialcomm.timeout = 1
def main():
while True:
i = input("input(RED/GREEN/YELLOW): ").strip()
if i == 'end':
print('End Program')
break
serialcomm.write(i.encode())
time.sleep(0.5)
print(serialcomm.readline().decode('ascii'))
serialcomm.close()
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment