0% found this document useful (0 votes)
7 views2 pages

Actividad12 Arduino NajlaeChaghouaoui

The document contains Arduino code for interacting with a button and an LED. It includes two main functionalities: turning the LED on when the button is pressed and varying the LED brightness through PWM. The code demonstrates the use of digital and analog outputs in an Arduino setup.

Uploaded by

fajr.jerrar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views2 pages

Actividad12 Arduino NajlaeChaghouaoui

The document contains Arduino code for interacting with a button and an LED. It includes two main functionalities: turning the LED on when the button is pressed and varying the LED brightness through PWM. The code demonstrates the use of digital and analog outputs in an Arduino setup.

Uploaded by

fajr.jerrar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

12.1.

INTERACCIÓN CON ARDUINO: PULSADOR

const int buttonPin = 4;


const int ledPin = 10;
void setup() {
pinMode(ledPin, OUTPUT);
pinMode(buttonPin, INPUT);
}
void loop() {
if (digitalRead(buttonPin) == HIGH) {
digitalWrite(ledPin, HIGH);
} else {
digitalWrite(ledPin, LOW);
}
}

const int ledPin = 10;

void setup() {
pinMode(ledPin, OUTPUT);
pinMode(buttonPin, INPUT);
}

void loop() {
if (digitalRead(buttonPin) == HIGH) {
digitalWrite(ledPin, HIGH);
} else {
digitalWrite(ledPin, LOW);
}
}
void setup() {
pinMode(LED, OUTPUT);
}

void loop() {
analogWrite(LED, 50);
delay(1000);
analogWrite(LED, 100);
delay(1000);
analogWrite(LED, 150);
delay(1000);
analogWrite(LED, 200);
delay(1000);
analogWrite(LED, 250);
delay(1000);
}

You might also like