Download presentation
Presentation is loading. Please wait.
Published byEustace Robinson Modified over 9 years ago
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); }
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.