ESP8266
TX danground ke Mega 2650 port serial 2
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial2.begin(115200);
}
void loop() {
// put your main code here, to run repeatedly:
delay(500);
char inChar[2];
if (Serial.available()>0)
{
for (int i=0; i<2; i++)
{
inChar[i] = Serial.read();
delay(10);
}
if (inChar[0] == 'x' && inChar[1] == '-' )
{
Serial.println("X- serial");
}
if (inChar[0] == 'x' && inChar[1] == '0')
{
Serial.println("X0 serila");
// goto x_0;
}
if (inChar[0] == 'x' && inChar[1] == '+')
{
Serial.println("X+ serial");
//goto x_plus;
}
if (inChar[0] == 'y' && inChar[1] == '-')
{
Serial.println("Y- serial");
//goto y_minus;
}
if (inChar[0] == 'y' && inChar[1] == '0')
{
Serial.println("Y0 serial");
//goto y_0;
}
if (inChar[0] == 'y' && inChar[1] == '+')
{
Serial.println("Y+ serial");
// goto y_plus;
}
if (inChar[0] == 'z' && inChar[1] == '-')
{
Serial.println("Z- serial");
//goto z_minus;
}
if (inChar[0] == 'z' && inChar[1] == '0')
{
Serial.println("Z0 serial");
// goto z_0;
}
if (inChar[0] == 'z' && inChar[1] == '+')
{
Serial.println("z+ serial");
//goto z_plus;
}
}
char inChar2[2];
if (Serial2.available()>0)
{
for (int i=0; i<2; i++)
{
inChar2[i] = Serial2.read();
delay(10);
}
if (inChar2[0] == 'x' && inChar2[1] == '-' )
{
Serial.println("X- serial");
}
if (inChar2[0] == 'x' && inChar2[1] == '0')
{
Serial.println("X0 serila");
// goto x_0;
}
if (inChar2[0] == 'x' && inChar2[1] == '+')
{
Serial.println("X+ serial");
//goto x_plus;
}
if (inChar2[0] == 'y' && inChar2[1] == '-')
{
Serial.println("Y- serial");
//goto y_minus;
}
if (inChar2[0] == 'y' && inChar2[1] == '0')
{
Serial.println("Y0 serial");
//goto y_0;
}
if (inChar[0] == 'y' && inChar[1] == '+')
{
Serial.println("Y+ serial");
// goto y_plus;
}
if (inChar2[0] == 'z' && inChar2[1] == '-')
{
Serial.println("Z- serial");
//goto z_minus;
}
if (inChar2[0] == 'z' && inChar2[1] == '0')
{
Serial.println("Z0 serial");
// goto z_0;
}
if (inChar2[0] == 'z' && inChar2[1] == '+')
{
Serial.println("z+ serial");
//goto z_plus;
}
}
}
Tidak ada komentar:
Posting Komentar