TUGAS PENDAHULUAN 1
PERCOBAAN 2
M1
Prinsip kerja pada rangkaian diatas dimana memakai indikator berupa seven segment yang mana dihubungkan kepada arduino uno pada tiap-tiap pinnya. yang mana pada arduino dihubungkan pada 8 pin (pin 2,3,4,5,6,7,8,9) ke kaki pin seven segment. yang mana tiap pin diseven segment mewakili dari LED pada seven segment itu sendiri. pada arduino uno telah diprogram agar dapat memunculkan angka pada seven segment itu sendiri. berdasarkan kondisi pada percobaan 2 ini dimana program diatur dari angka 9 sampai 1 secara berulang yang mana menggunakan void loop(); pada program yang nantinya akan pada void loop tersebut akan memanggil fungsi dari Void nine(); hingga Void one(); yang mana telah diatur pada fungsi void loop();
- Listing Program
byte pin[] = {2, 3, 4, 5, 6, 7, 8, 9};
void setup() {pinMode (2,OUTPUT);pinMode (3,OUTPUT);pinMode (4,OUTPUT);pinMode (5,OUTPUT);pinMode (6,OUTPUT);pinMode (7,OUTPUT);pinMode (8,OUTPUT);pinMode (9,OUTPUT);}void loop() {nine();eight();seven();six();five();four();three();two();one();}void one(){digitalWrite(2, HIGH);digitalWrite(3, LOW);digitalWrite(4, LOW);digitalWrite(5, LOW);digitalWrite(6, LOW);digitalWrite(7, HIGH);digitalWrite(8, HIGH);digitalWrite(9, LOW);delay(500);}void two(){digitalWrite(2, HIGH);digitalWrite(3, HIGH);digitalWrite(4, LOW);digitalWrite(5, HIGH);digitalWrite(6, HIGH);digitalWrite(7, LOW);digitalWrite(8, HIGH);digitalWrite(9, HIGH);delay(500);}void three (){digitalWrite(2, HIGH);digitalWrite(3, HIGH);digitalWrite(4, LOW);digitalWrite(5, LOW);digitalWrite(6, HIGH);digitalWrite(7, HIGH);digitalWrite(8, HIGH);digitalWrite(9, HIGH);delay(500);}void four(){digitalWrite(2, HIGH);digitalWrite(3, HIGH);digitalWrite(4, HIGH);digitalWrite(5, LOW);digitalWrite(6, LOW);digitalWrite(7, HIGH);digitalWrite(8, HIGH);digitalWrite(9, LOW);delay(500);}void five(){digitalWrite(2, HIGH);digitalWrite(3, HIGH);digitalWrite(4, HIGH);digitalWrite(5, LOW);digitalWrite(6, HIGH);digitalWrite(7, HIGH);digitalWrite(8, LOW);digitalWrite(9, HIGH);delay(500);}void six(){digitalWrite(2, HIGH);digitalWrite(3, HIGH);digitalWrite(4, HIGH);digitalWrite(5, HIGH);digitalWrite(6, HIGH);digitalWrite(7, HIGH);digitalWrite(8, LOW);digitalWrite(9, HIGH);delay(500);}void seven(){digitalWrite(2, HIGH);digitalWrite(3, LOW);digitalWrite(4, HIGH);digitalWrite(5, HIGH);digitalWrite(6, HIGH);digitalWrite(7, LOW);digitalWrite(8, LOW);digitalWrite(9, HIGH);delay(500);}void eight(){digitalWrite(2, HIGH);digitalWrite(3, HIGH);digitalWrite(4, HIGH);digitalWrite(5, HIGH);digitalWrite(6, HIGH);digitalWrite(7, HIGH);digitalWrite(8, LOW);digitalWrite(9, LOW);delay(500);}void nine(){digitalWrite(2, HIGH);digitalWrite(3, HIGH);digitalWrite(4, HIGH);digitalWrite(5, HIGH);digitalWrite(6, LOW);digitalWrite(7, HIGH);digitalWrite(8, HIGH);digitalWrite(9, HIGH);delay(500);}
Tidak ada komentar:
Posting Komentar