Fig. 1 Microcontroller Arduino Duemilanove - PLC with which I started studying about Arduino
1. LED Control with PWM signal:
void setup() {pinMode(13, OUTPUT);
}
void loop() {
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, LOW);
delay(1000);
}
2. LED control variable intensity:
void setup() {pinMode(11, OUTPUT);
}
void loop() {
for (int i = 0; i < 255; i++){
analogWrite(11, i);
delay(50);
}
for (int i = 255; i > 0; i--){
analogWrite(11, i);
delay(50);
}
}
3. Sound with Arduino (siren):
void setup() {pinMode(11, OUTPUT);
}
void loop() {
for (int i = 1500; i < 4000; i++) {
tone(11, i);
delay(10);
}
for (int i = 4000; i > 1500; i--) {
tone(11, i);
delay(10);
}
}
No comments:
Post a Comment