Arduino deneyi 02
Traffic Light
Beginner · 40 min · Sequences
Control three LEDs in a timed red, yellow and green traffic-light sequence.
Malzemeler
- Arduino Uno
- Red, yellow and green LEDs
- 3 × 220 Ω resistors
- Breadboard
- Jumper wires
- USB data cable
Bağlantı
- Connect pins 10, 11 and 12 through separate 220 Ω resistors to the red, yellow and green LED anodes.
- Connect all three LED cathodes to GND.
Kod
const int red = 10;
const int yellow = 11;
const int green = 12;
void setup() {
pinMode(red, OUTPUT);
pinMode(yellow, OUTPUT);
pinMode(green, OUTPUT);
}
void loop() {
digitalWrite(red, HIGH); delay(3000); digitalWrite(red, LOW);
digitalWrite(green, HIGH); delay(3000); digitalWrite(green, LOW);
digitalWrite(yellow, HIGH); delay(1000); digitalWrite(yellow, LOW);
}
Ne olmalı?
Only one LED is on at a time, following a repeating traffic-light sequence.
Meydan okuma
Add a short red-and-yellow phase before green.
Güvenlik ve sorun giderme
- Bağlantıyı değiştirmeden önce gücü kes.
- Her LED ile direnç kullan.
- Kart ve port seçimini Arduino IDE'de kontrol et.
- Her kablonun koddaki pin numarasıyla eşleştiğini doğrula.
Not: Ders metinleri İngilizcedir. Orijinal Türkçe çalışma kâğıdı PDF olarak indirilebilir.
