Question: Using C programming and this code as a base. Write a code that uses pulse modulation to generate a signal with a period of 1000
Using C programming and this code as a base. Write a code that uses pulse modulation to generate a signal with a period of 1000 ms, and a 50% duty cycle for 5 seconds. This should cause the LED to flash on and off with equal time, once a second, for 5 seconds. If you enter a period of 1000 ms, and a 90% duty cycle for 5 seconds, it should cause the LED to flash on and off, once a second for 5 seconds, where it is on for 90% of the time. If you enter a period of 25 ms, and a 25% duty cycle for 5 seconds, it should cause the LED to appear to be on constantly at a quarter of its normal brightness. ** note this code is being run on a raspberry pi using geany.
include
#include
#include
int main()
{
unsigned int stime = 0;
wiringPiSetup();
//note that pin 0 is actually gipio pin 11
pinMode (0,OUTPUT);
do
{
digitalWrite (0,HIGH);
stime=millis();
while (millis()-stime < 1000);
digitalWrite (0,LOW);
stime=millis();
while (millis()-stime < 1000);
}while (1);
getchar();
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
