Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Dharini Kapoor
- 4.3 Experiment
- December 6th, 2020
- */
- void setup() {
- pinMode(13, OUTPUT);
- pinMode(12, OUTPUT);
- pinMode(6, OUTPUT);
- pinMode(8, INPUT);
- pinMode(2, OUTPUT);
- pinMode(4, OUTPUT);
- pinMode(3, OUTPUT);
- }
- void loop() {
- if (digitalRead(8) == HIGH) {
- digitalWrite(13, HIGH);
- digitalWrite(4, HIGH);
- digitalWrite(2, HIGH);
- delay(1000);// delay for one second
- digitalWrite(12, HIGH);
- delay(330);// delay for 330 mili seconds
- // fade in from min to max in increments of 5 points:
- for (int fadeValue = 0 ; fadeValue <= 255; fadeValue += 5) {
- // sets the value (range from 0 to 255):
- analogWrite(6, fadeValue);
- // wait for 30 milliseconds to see the dimming effect
- delay(30);
- }
- // fade out from max to min in increments of 5 points:
- for (int fadeValue = 255 ; fadeValue >= 0; fadeValue -= 5) {
- // sets the value (range from 0 to 255):
- analogWrite(6, fadeValue);
- // wait for 30 milliseconds to see the dimming effect
- delay(30);
- }
- // fade in from min to max in increments of 5 points:
- for (int fadeValue = 0 ; fadeValue <= 255; fadeValue += 5) {
- // sets the value (range from 0 to 255):
- analogWrite(3, fadeValue);
- // wait for 30 milliseconds to see the dimming effect
- delay(30);
- }
- // fade out from max to min in increments of 5 points:
- for (int fadeValue = 255 ; fadeValue >= 0; fadeValue -= 5) {
- // sets the value (range from 0 to 255):
- analogWrite(3, fadeValue);
- // wait for 30 milliseconds to see the dimming effect
- delay(30);
- }
- } else {
- digitalWrite(13, LOW);
- delay(1000); // delay for one second
- digitalWrite(12, LOW); // turn of pin 12
- delay(4000); // delay for 4 second
- digitalWrite(4, LOW);
- delay(1000); // delay for one second
- digitalWrite(2, LOW);
- delay(1000); // delay for one second
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement