Arduino ile Led Rotating beacon Uygulaması - Kumanda kontrolü ile farkı desenler
Kumanda kontrolü ile farklı görünümlü beacon desenlerini kontrol edebilmek için kod bu, hangi desenin daha gerçekçi gözükeceğini denemek, zamanlamalarla ve parlaklıklarla oynamak lazım...
Devresi de bu:
Kumanda kontrolü ile farklı görünümlü beacon desenlerini kontrol edebilmek için kod bu, hangi desenin daha gerçekçi gözükeceğini denemek, zamanlamalarla ve parlaklıklarla oynamak lazım...
Kod:
/* 4 Rotating Led with PWM
modified 12/01/2015 - version 0.31
*/
int beaconLed[] = {3,9,10,11}; // The pin numbers to attach the leds
int rxPin = 12; // The pin number to attach the receiver signal
int rxDuration = 0; // Variable to hold receiver signal length
void setup() {
pinMode(rxPin, INPUT);
}
void loop() {
rxDuration = pulseIn(rxPin, HIGH);
if (rxDuration > 1600) {
beacon_pattern_simple(100);
} else if (rxDuration > 1400) {
beacon_pattern_smooth(50);
} else {
beacon_pattern_sharp(50);
}
}
void beacon_pattern_simple(int beaconDelay) {
analogWrite(beaconLed[0], 255); // STEP1
analogWrite(beaconLed[1], 15); // STEP1
analogWrite(beaconLed[2], 0); // STEP1
analogWrite(beaconLed[3], 15); // STEP1
delay(beaconDelay); // Wait in every rotating position
analogWrite(beaconLed[0], 15); // STEP2
analogWrite(beaconLed[1], 255); // STEP2
analogWrite(beaconLed[2], 15); // STEP2
analogWrite(beaconLed[3], 0); // STEP2
delay(beaconDelay); // Wait in every rotating position
analogWrite(beaconLed[0], 0); // STEP3
analogWrite(beaconLed[1], 15); // STEP3
analogWrite(beaconLed[2], 255); // STEP3
analogWrite(beaconLed[3], 15); // STEP3
delay(beaconDelay); // Wait in every rotating position
analogWrite(beaconLed[0], 15); // STEP4
analogWrite(beaconLed[1], 0); // STEP4
analogWrite(beaconLed[2], 15); // STEP4
analogWrite(beaconLed[3], 255); // STEP4
delay(beaconDelay); // Wait in every rotating position
}
void beacon_pattern_smooth(int beaconDelay) {
analogWrite(beaconLed[0], 255); // STEP1
analogWrite(beaconLed[1], 15); // STEP1
analogWrite(beaconLed[2], 0); // STEP1
analogWrite(beaconLed[3], 15); // STEP1
delay(beaconDelay); // Wait in every rotating position
analogWrite(beaconLed[0], 63); // STEP2
analogWrite(beaconLed[1], 63); // STEP2
analogWrite(beaconLed[2], 3); // STEP2
analogWrite(beaconLed[3], 3); // STEP2
delay(beaconDelay); // Wait in every rotating position
analogWrite(beaconLed[0], 15); // STEP3
analogWrite(beaconLed[1], 255); // STEP3
analogWrite(beaconLed[2], 15); // STEP3
analogWrite(beaconLed[3], 0); // STEP3
delay(beaconDelay); // Wait in every rotating position
analogWrite(beaconLed[0], 3); // STEP4
analogWrite(beaconLed[1], 63); // STEP4
analogWrite(beaconLed[2], 63); // STEP4
analogWrite(beaconLed[3], 3); // STEP4
delay(beaconDelay); // Wait in every rotating position
analogWrite(beaconLed[0], 0); // STEP5
analogWrite(beaconLed[1], 15); // STEP5
analogWrite(beaconLed[2], 255); // STEP5
analogWrite(beaconLed[3], 15); // STEP5
delay(beaconDelay); // Wait in every rotating position
analogWrite(beaconLed[0], 3); // STEP6
analogWrite(beaconLed[1], 3); // STEP6
analogWrite(beaconLed[2], 63); // STEP6
analogWrite(beaconLed[3], 63); // STEP6
delay(beaconDelay); // Wait in every rotating position
analogWrite(beaconLed[0], 15); // STEP7
analogWrite(beaconLed[1], 0); // STEP7
analogWrite(beaconLed[2], 15); // STEP7
analogWrite(beaconLed[3], 255); // STEP7
delay(beaconDelay); // Wait in every rotating position
analogWrite(beaconLed[0], 63); // STEP8
analogWrite(beaconLed[1], 3); // STEP8
analogWrite(beaconLed[2], 3); // STEP8
analogWrite(beaconLed[3], 63); // STEP8
delay(beaconDelay); // Wait in every rotating position
}
void beacon_pattern_sharp(int beaconDelay) {
analogWrite(beaconLed[0], 255); // STEP1
analogWrite(beaconLed[1], 0); // STEP1
analogWrite(beaconLed[2], 0); // STEP1
analogWrite(beaconLed[3], 0); // STEP1
delay(beaconDelay); // Wait in every rotating position
analogWrite(beaconLed[0], 63); // STEP2
analogWrite(beaconLed[1], 63); // STEP2
analogWrite(beaconLed[2], 0); // STEP2
analogWrite(beaconLed[3], 0); // STEP2
delay(beaconDelay); // Wait in every rotating position
analogWrite(beaconLed[0], 0); // STEP3
analogWrite(beaconLed[1], 255); // STEP3
analogWrite(beaconLed[2], 0); // STEP3
analogWrite(beaconLed[3], 0); // STEP3
delay(beaconDelay); // Wait in every rotating position
analogWrite(beaconLed[0], 0); // STEP4
analogWrite(beaconLed[1], 63); // STEP4
analogWrite(beaconLed[2], 63); // STEP4
analogWrite(beaconLed[3], 0); // STEP4
delay(beaconDelay); // Wait in every rotating position
analogWrite(beaconLed[0], 0); // STEP5
analogWrite(beaconLed[1], 0); // STEP5
analogWrite(beaconLed[2], 255); // STEP5
analogWrite(beaconLed[3], 0); // STEP5
delay(beaconDelay); // Wait in every rotating position
analogWrite(beaconLed[0], 0); // STEP6
analogWrite(beaconLed[1], 0); // STEP6
analogWrite(beaconLed[2], 63); // STEP6
analogWrite(beaconLed[3], 63); // STEP6
delay(beaconDelay); // Wait in every rotating position
analogWrite(beaconLed[0], 0); // STEP7
analogWrite(beaconLed[1], 0); // STEP7
analogWrite(beaconLed[2], 0); // STEP7
analogWrite(beaconLed[3], 255); // STEP7
delay(beaconDelay); // Wait in every rotating position
analogWrite(beaconLed[0], 63); // STEP8
analogWrite(beaconLed[1], 0); // STEP8
analogWrite(beaconLed[2], 0); // STEP8
analogWrite(beaconLed[3], 63); // STEP8
delay(beaconDelay); // Wait in every rotating position
}
Devresi de bu:
Bu RESMİ görmek için izniniz yok. Giriş yap veya üye ol