Skip to content

Instantly share code, notes, and snippets.

@korayal
Created December 13, 2012 11:04
Show Gist options
  • Save korayal/4275766 to your computer and use it in GitHub Desktop.
Save korayal/4275766 to your computer and use it in GitHub Desktop.
void setup() {
Serial.begin(9600);
//buradan sonrası sadece Mega'lar için geçerli
//Serial1.begin(19200);
//Serial2.begin(38400);
//Serial3.begin(4800);
}
void loop() {
String Seri;
if ((Seri = SeriOku(Serial)) != "") Serial.println(Seri);
//buradan sonrası sadece Mega'lar için geçerli
// if ((Seri = SeriOku(Serial1)) != "") Serial.println(Seri);
// if ((Seri = SeriOku(Serial2)) != "") Serial.println(Seri);
// if ((Seri = SeriOku(Serial3)) != "") Serial.println(Seri);
//burası kullandığınız baud rate e göre değişiklik gösterecektir
delay(200);
}
String SeriOku(HardwareSerial SeriPort) {
String SeriString = "";
char SeriByte[1];
// bağlanacağımız SeriPort'ta okunacak veri olduğu sürece
// 1 Byte'lık bir karakter okuyup bunu stringe ekleyelim
while (SeriPort.available()) SeriString += (SeriByte[0] = SeriPort.read());
return SeriString;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment