-
-
Save nefo-mi/3361233 to your computer and use it in GitHub Desktop.
Arduino Serial
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
#include <LiquidCrystal.h> | |
int incomingByte; | |
char inByte; | |
String inMsg; | |
LiquidCrystal lcd(7,8,9,10,11,12,13); | |
void setup() | |
{ | |
lcd.begin(2, 16); | |
lcd.clear(); | |
lcd.print("*Hello World*"); | |
lcd.setCursor(1, 1); | |
lcd.print("homuhomu"); | |
Serial.begin(9600); | |
Serial.println("setupDone"); | |
} | |
void loop() | |
{ | |
if (Serial.available() > 0) { | |
inByte = Serial.read(); | |
if((inByte >= 65 && inByte <= 90) || (inByte >= 97 && inByte <= 122) | |
|| (inByte >= 48 && inByte <= 57) || (inByte == 43) | |
|| (inByte == 61) || (inByte == 63)){ | |
inMsg.concat(inByte); | |
} | |
} | |
if (inByte == 10 || inByte == 13){ | |
inByte = 0; | |
lcd.clear(); | |
lcd.print(inMsg); | |
inMsg = ""; | |
} | |
} |
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
[1] pry(main)> require 'serialport' | |
=> true | |
[2] pry(main)> sp = SerialPort.new("/dev/ttyACM0", 9600, 8, 1, SerialPort::NONE) | |
=> #<SerialPort:fd 5> | |
[3] pry(main)> sp.puts "homuhomu" | |
=> nil |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment