Skip to content

Instantly share code, notes, and snippets.

@GiovanniBalestrieri
Created July 27, 2015 23:29
Show Gist options
  • Save GiovanniBalestrieri/61503e9dac21e9e6ee07 to your computer and use it in GitHub Desktop.
Save GiovanniBalestrieri/61503e9dac21e9e6ee07 to your computer and use it in GitHub Desktop.
Serial Communication between Matlab and Arduino
int a=0;
void setup()
{
Serial.begin(9600);
}
void loop()
{
serialRoutine();
}
void serialRoutine()
{
if(Serial.available()>0)
{
char t = Serial.read();
if (t =='T')
{
Serial.println("Ok");
}
else if (t== 'M')
{
a++;
Serial.println(a);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment