This provides a template for how to use a .h file to help organize a larger program into classes.

Dependencies:   mbed

Committer:
mattshuman
Date:
Sat Aug 13 01:25:25 2016 +0000
Revision:
0:dff21578688b
Child:
1:a0232594b518
This provides a template about how to use a .h file to organize programs into logical classes.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mattshuman 0:dff21578688b 1 #include "mbed.h"
mattshuman 0:dff21578688b 2 // this class file is a template on using .h files.
mattshuman 0:dff21578688b 3 class Blinker
mattshuman 0:dff21578688b 4 {
mattshuman 0:dff21578688b 5 public:
mattshuman 0:dff21578688b 6 Blinker(void) {
mattshuman 0:dff21578688b 7 // _pin(pin) means pass pin to the Blinker Constructor
mattshuman 0:dff21578688b 8 };
mattshuman 0:dff21578688b 9 // class method to blink and LED based on the PwmOut class
mattshuman 0:dff21578688b 10 void blink(PwmOut outputLED, float frequency, float brightness) {
mattshuman 0:dff21578688b 11 outputLED.period(.001f);
mattshuman 0:dff21578688b 12 outputLED = 1- brightness;
mattshuman 0:dff21578688b 13 float duration = (1.0/frequency)/2;
mattshuman 0:dff21578688b 14 wait(duration);
mattshuman 0:dff21578688b 15 outputLED = 1.0;
mattshuman 0:dff21578688b 16 wait(duration);
mattshuman 0:dff21578688b 17 };
mattshuman 0:dff21578688b 18
mattshuman 0:dff21578688b 19 private:
mattshuman 0:dff21578688b 20
mattshuman 0:dff21578688b 21 };