Question

Using pulse width modulation and interrupts create a code in adruino where you will push a...

Using pulse width modulation and interrupts create a code in adruino where you will push a button on the MCU which triggers an interrupt.
Once triggered, the LED on the development board must fade-in
(min to max intensity) for 2 seconds, stay at maximum brightness for 5 seconds,
and then fade-out (max brightness to off) with a duration again of two seconds.
cannot make use of "delay" or equivalent routines to implement
the 2 or 5 second intervals but must make use of the timers incorporated into
MCU. Furthermore, you should implement to LED intensity variations through
the use of pulse-width modulation

Homework Answers

Answer #1

const int buutonPin=2 // the number of the push button pin

constintledPin=13; //the number of the led pin

//variable will change:

int buttonState=0; //variable for reading the pushbutton status

void setup(){

//initialise te led pin as and output

pinMode(ledPin,output);

//initialize the pushbotton pin as an input:

}

void loop() {

//read the state of the pushbotton value:

buttonState=digitalRead(buttonReadpin);

//check the push button is pressed

//if it is, buttonState is high:

if(buttonState==High){

//turn LED on:

digitalWrite(ledPin,High);

}

else{

//turn LED off:

digitalWrite(ledPin ,LOW);

}

}

// NOTE:- you can change the VARIABLE AS PER YOUR REQUIREMENT.

//IF YOOU HAVE ANY DOUBT PLEASE LET ME KNOW. I WILL REPLY AS SOON AS POSSIBLE. Thanks.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions