Presentation is loading. Please wait.

Presentation is loading. Please wait.

Autumn, 2014C.-S. Shieh, EC, KUAS, Taiwan1 智慧電子應用設計導論 (1/3) Digital Input/Output Chin-Shiuh Shieh ( 謝欽旭 ) Department of.

Similar presentations


Presentation on theme: "Autumn, 2014C.-S. Shieh, EC, KUAS, Taiwan1 智慧電子應用設計導論 (1/3) Digital Input/Output Chin-Shiuh Shieh ( 謝欽旭 ) Department of."— Presentation transcript:

1 Autumn, 2014C.-S. Shieh, EC, KUAS, Taiwan1 智慧電子應用設計導論 (1/3) Digital Input/Output Chin-Shiuh Shieh ( 謝欽旭 ) http://bit.kuas.edu.tw/~csshieh Department of Electronic Engineering National Kaohsiung University of Applied Sciences, Taiwan

2 Autumn, 2014C.-S. Shieh, EC, KUAS, Taiwan2 Digital Input/Output

3 Autumn, 2014C.-S. Shieh, EC, KUAS, Taiwan3 Digital Input/Output (cont) pinMode(pin,mode); digitalWrite(pin,value); digitalRead(pin);

4 Autumn, 2014C.-S. Shieh, EC, KUAS, Taiwan4 Example – LED

5 Autumn, 2014C.-S. Shieh, EC, KUAS, Taiwan5 Example – LED (cont) void setup() { int pin; for(pin=14;pin<=21;pin++) { pinMode(pin,OUTPUT); digitalWrite(pin,HIGH); } void loop() { int pin; for(pin=14;pin<=21;pin++) { digitalWrite(pin,LOW); delay(100); digitalWrite(pin,HIGH); }

6 Autumn, 2014C.-S. Shieh, EC, KUAS, Taiwan6 Example DIP Switch

7 Autumn, 2014C.-S. Shieh, EC, KUAS, Taiwan7 Example DIP Switch (cont) void setup() { int pin; for(pin=14;pin<=21;pin++) { pinMode(pin,OUTPUT); pinMode(pin*2+3,INPUT); } void loop() { int pin; for(pin=14;pin<=21;pin++) { digitalWrite(pin,digitalRead(pin*2+3)); }

8 Autumn, 2014C.-S. Shieh, EC, KUAS, Taiwan8 Example - Button

9 Autumn, 2014C.-S. Shieh, EC, KUAS, Taiwan9 Example – Button (cont) int button = 2;int LED = 13; void setup() { pinMode(button,INPUT); pinMode(LED,OUTPUT);digitalWrite(LED,LOW); } void loop() { if(digitalRead(button)==LOW) { for(int i=0;i<3;i++) { digitalWrite(LED,HIGH);delay(500); digitalWrite(LED,LOW);delay(500); }


Download ppt "Autumn, 2014C.-S. Shieh, EC, KUAS, Taiwan1 智慧電子應用設計導論 (1/3) Digital Input/Output Chin-Shiuh Shieh ( 謝欽旭 ) Department of."

Similar presentations


Ads by Google