In: Electrical Engineering
write a program for the msp430fr6989
Using the general purpose timer, specifically the ACLK, create a program which makes LED1 stay on for 4 seconds and off for 2 seconds and repeat indefinitely.
Modify the above program to extend the timing to 20 and 10 seconds, respectively.
void setup() {
pinMode(led1, OUTPUT); // initialize digital pin led1 as an output.
int counter=0;
}
void loop()
{
digitalWrite(led1, HIGH); // turn the led1 on (HIGH is the voltage level)
delay(4000); // led1 stay on for 4seconds=4000 milliseconds
digitalWrite(led1, LOW); // turn the led1 off by making the voltage LOW
delay(2000); // led1 stay off for 2 seconds=2000 milliseconds
counter++; // this statement makes the program indefinetely repeat itself
}
Now program for 20 seconds ON and 10 seconds OFF is shown below
void setup()
{
pinMode(led1, OUTPUT);
int counter=0;
}
void loop()
{
digitalWrite(led1, HIGH);
delay(20000); // 20 seconds = 20000 milliseconds
digitalWrite(led1, LOW);
delay(10000); // 10seconds =10000 milliseconds
counter++;
}
IF YOU HAVE QUERY PLEASE POST A COMMENT , LIKE MY ANSEWER THANKS IN ADVANCE