A collection of examples organized from basics to advanced.

Dependencies:   mbed SDFileSystem

Mbed online compiler has no facility to easily manage a lot of programs or organized them in to related folders. This makes creating an examples and sample pack difficult.

This repository contains a single main.cpp file (which does very little), and a BuildOptions.h file. Simply uncomment the example you would like to compile from the build options. Each example is wrapped in a compiler directive.

If the directive does not include a description comment, it likely does not exist yet. If you would like to contribute to the Examples project, please contact me or fork and issue a pull request.

Committer:
epremeaux
Date:
Tue Jul 09 02:23:18 2019 +0000
Revision:
2:17a5c34b3a79
Parent:
0:b471f7764d46
Added SD card examples. Had to roll back the MBED library to maintain SDFileSystem compatability

Who changed what in which revision?

UserRevisionLine numberNew contents of line
epremeaux 0:b471f7764d46 1
epremeaux 0:b471f7764d46 2 #ifdef COMPILE_Analog_In
epremeaux 0:b471f7764d46 3
epremeaux 0:b471f7764d46 4 AnalogIn analog_value(A0);
epremeaux 0:b471f7764d46 5
epremeaux 0:b471f7764d46 6 DigitalOut led(LED1);
epremeaux 0:b471f7764d46 7
epremeaux 0:b471f7764d46 8 int main()
epremeaux 0:b471f7764d46 9 {
epremeaux 0:b471f7764d46 10 float meas_r;
epremeaux 0:b471f7764d46 11 float meas_v;
epremeaux 0:b471f7764d46 12
epremeaux 0:b471f7764d46 13 printf("\nAnalogIn example\n");
epremeaux 0:b471f7764d46 14
epremeaux 0:b471f7764d46 15 while(1) {
epremeaux 0:b471f7764d46 16
epremeaux 0:b471f7764d46 17 meas_r = analog_value.read(); // Read the analog input value (value from 0.0 to 1.0 = full ADC conversion range)
epremeaux 0:b471f7764d46 18 meas_v = meas_r * 3300; // Converts value in the 0V-3.3V range
epremeaux 0:b471f7764d46 19
epremeaux 0:b471f7764d46 20 // Display values
epremeaux 0:b471f7764d46 21 printf("measure = %f = %.0f mV\n", meas_r, meas_v);
epremeaux 0:b471f7764d46 22
epremeaux 0:b471f7764d46 23 // LED is ON is the value is below 1V
epremeaux 0:b471f7764d46 24 if (meas_v < 1000) {
epremeaux 0:b471f7764d46 25 led = 1; // LED ON
epremeaux 0:b471f7764d46 26 } else {
epremeaux 0:b471f7764d46 27 led = 0; // LED OFF
epremeaux 0:b471f7764d46 28 }
epremeaux 0:b471f7764d46 29
epremeaux 0:b471f7764d46 30 wait(1.0); // 1 second
epremeaux 0:b471f7764d46 31 }
epremeaux 0:b471f7764d46 32 }
epremeaux 0:b471f7764d46 33
epremeaux 0:b471f7764d46 34
epremeaux 0:b471f7764d46 35 #endif