Charles Tritt / Mbed 2 deprecated Blink_FET_Variable

Dependencies:   mbed

Committer:
CSTritt
Date:
Thu May 07 15:37:04 2020 +0000
Revision:
3:665ae1f64bf0
Parent:
2:1f9267d3f3f4
Variable rate version of my FET blank program.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
rossatmsoe 0:293359e38af0 1 /*
CSTritt 3:665ae1f64bf0 2 Project: Blink_FET_Variable
CSTritt 2:1f9267d3f3f4 3 File: main.cpp
CSTritt 2:1f9267d3f3f4 4 Last revised by: Dr. C. S. Tritt
CSTritt 3:665ae1f64bf0 5 Last revision on: 5/7/20 (v. 1.0)
CSTritt 2:1f9267d3f3f4 6
CSTritt 3:665ae1f64bf0 7 Turns on D4 for 0.7*n second, then off for 0.3*n second, repeatedly. Where n
CSTritt 3:665ae1f64bf0 8 is a scaled pot setting obtained from A1.
rossatmsoe 0:293359e38af0 9
rossatmsoe 0:293359e38af0 10 This example code is in the public domain.
rossatmsoe 0:293359e38af0 11 */
rossatmsoe 0:293359e38af0 12 #include "mbed.h"
CSTritt 3:665ae1f64bf0 13 // Scale factor (seconds)
CSTritt 3:665ae1f64bf0 14 double SCALE = 3.0;
CSTritt 3:665ae1f64bf0 15 // Analog pot reading used to adjust blink interval.
CSTritt 3:665ae1f64bf0 16 AnalogIn myA_in(A1);
CSTritt 2:1f9267d3f3f4 17 // Construct a digital output object called myD4 and connect it to D4.
CSTritt 3:665ae1f64bf0 18 DigitalOut myD_out(D4);
CSTritt 2:1f9267d3f3f4 19
rossatmsoe 0:293359e38af0 20 int main() { // This curly brace marks the beginning of the main function.
CSTritt 2:1f9267d3f3f4 21 // Loop forever.
CSTritt 1:9f6f3af9aaaa 22 while(true) { // This curly brace marks the start of the repeated actions.
CSTritt 3:665ae1f64bf0 23 double n = SCALE*myA_in;
CSTritt 3:665ae1f64bf0 24 myD_out = 1; // Turn on D4 by "storing" a 1 in it.
CSTritt 3:665ae1f64bf0 25 wait(0.7*n); // wait(x) will pause for a given number of seconds.
CSTritt 3:665ae1f64bf0 26 myD_out = 0; // Turn off D4 by "storing" a 0 in it.
CSTritt 3:665ae1f64bf0 27 wait(0.3*n); // Wait another 0.3 seconds.
CSTritt 2:1f9267d3f3f4 28 } // end of repeated actions.
CSTritt 2:1f9267d3f3f4 29 } // end of main function.