Skip to content

Instantly share code, notes, and snippets.

@Piyoshi
Created February 13, 2016 12:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Piyoshi/48a670ac389bc3cba566 to your computer and use it in GitHub Desktop.
Save Piyoshi/48a670ac389bc3cba566 to your computer and use it in GitHub Desktop.
const char SWEET = 'S';
const char BITTER = 'B';
const char HOT = 'H';
int Lx, Ly;
bool isExit = false;
char input;
void setup()
{
Serial.begin(9600);
Serial.println("Hello Computer");
//pinMode(11, OUTPUT);
}
void loop()
{
if (Serial.available())
{
int i = 0;
delay(100);
input = Serial.read();
Serial.write(input);
switch (input)
{
case SWEET:
isExit = true;
spinMotor(11);
delay(2000);
break;
case BITTER:
break;
case HOT:
break;
default:
break;
}
}
if (isExit) return;
spinMotor(11);
stopMotor(11);
}
void spinMotor(unsigned int pin)
{
digitalWrite(11,HIGH); //11番ピンの出力をHIGH = 5Vにする
delay(1000); //1000ミリ秒 = 1秒待つ
}
void stopMotor(unsigned int pin)
{
digitalWrite(11,LOW); //11番ピンの出力をLOW = 0Vにする
//delay(1000); //1000ミリ秒 = 1秒待つ
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment