Skip to content

Instantly share code, notes, and snippets.

@chairco
Created June 19, 2018 03:53
Show Gist options
  • Save chairco/f5972243c22d456aaba6c28ad2433942 to your computer and use it in GitHub Desktop.
Save chairco/f5972243c22d456aaba6c28ad2433942 to your computer and use it in GitHub Desktop.
arduino practice

控制 led 燈

  • 1411 modem, command
  • 1413 debug, upload program
#define BAUDRATE 19200
#define LED_PIN 13

void setup() {
  // put your setup code here, to run once:
  Serial.begin(BAUDRATE);
  pinMode(LED_PIN, OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
  int d;
  while(Serial.available()){
    d = Serial.read();
    if(d == '0'){
      digitalWrite(LED_PIN, LOW);   #熄滅
    }
    else if(d == '1'){
      digitalWrite(LED_PIN, HIGH);  #亮燈
    }
   }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment