Wenn-Programm: Unterschied zwischen den Versionen
Aus RMG-Wiki
Zeile 17: | Zeile 17: | ||
} | } | ||
</pre> | </pre> | ||
+ | |||
+ | |||
+ | anderes: | ||
+ | void setup() | ||
+ | { | ||
+ | pinMode(7,OUTPUT); //LED | ||
+ | pinMode(8,OUTPUT); //Lautsprecher | ||
+ | } | ||
+ | void loop() | ||
+ | { | ||
+ | digitalWrite(7,HIGH); //LED an | ||
+ | delay(2000); // 2sec verz. | ||
+ | digitalWrite(7,LOW); //Led aus | ||
+ | tone(8,20000,1000); // Ton an | ||
+ | delay(2000); // 2sec verz. | ||
+ | } |
Version vom 15. Mai 2015, 11:15 Uhr
void setup() { pinMode(13,OUTPUT); pinMode(7,INPUT); } void loop() { if(digitalRead(7)==HIGH) { digitalWrite(13,HIGH); } if(digitalRead(7)==LOW) { digitalWrite(13,LOW); } }
anderes:
void setup()
{
pinMode(7,OUTPUT); //LED pinMode(8,OUTPUT); //Lautsprecher
} void loop() {
digitalWrite(7,HIGH); //LED an delay(2000); // 2sec verz. digitalWrite(7,LOW); //Led aus tone(8,20000,1000); // Ton an delay(2000); // 2sec verz.
}