ARDUINO = TO DISPLAY ANALOG AND DIGITAL PULSES WITH LED

 TO DISPLAY ANALOG AND DIGITAL PULSES WITH LED


C LANGUAGE CODE


int svet = 0;//initial value

int fade = 5; // Step of changing the brightness of the LED

void setup() {

  // put your setup code here, to run once:

 pinMode(9, OUTPUT); // Using Pin9 for the withdrawal operation

    pinMode(10, OUTPUT);

}


void loop() {

  // put your main code here, to run repeatedly:

// Set the brightness of the LED to Pin9

    analogWrite(9, svet);

// Change the brightness by adding the given amount of fade in each cycle

    svet = svet + fade;

// Change the order of fading at a minimum and maximum brightness

    if (svet == 0 || svet == 255) 

    {

        fade = -fade;

        digitalWrite(10, HIGH);

        delay(100);

        digitalWrite(10, LOW);

        delay(100);

    }

    delay(20); // Set a little pause for the effect

}



     


Comments