conehead NZ
/
Ass2
Beats and Bars - Assignment 2
Diff: main.cpp
- Revision:
- 0:690b6f38fac1
diff -r 000000000000 -r 690b6f38fac1 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sun Oct 01 07:00:36 2017 +0000 @@ -0,0 +1,27 @@ +// Damon Hill - 14234098 - 159.270 +// Assignment 2 - Beats and Bars +#include "mbed.h" + +PwmOut yellowLED(LED1); // declare LED outputs +PwmOut blueLED(PA_7); + +unsigned int beatA,beatB; // declare beats and PWM period +float periodA, periodB; + +int main() +{ + beatA = 3; // set LED beats + beatB = 4; + periodA = 12/beatA; // 12/beat to get time for one beat in a 12 second bar + periodB = 12/beatB; + + yellowLED = 1; //turn LEDs high at start of bar + blueLED = 1; + + yellowLED.period(periodA); //set period + blueLED.period(periodB); + yellowLED.pulsewidth(1); //pulse led for 1 second + blueLED.pulsewidth(1); + + while (1); +} \ No newline at end of file