Foam device testing

Fork of AnalogIn_HelloWorld by mbed_example

Committer:
wspec
Date:
Wed May 10 05:13:19 2017 +0000
Revision:
3:5fc7b56ebe8c
Parent:
0:101a12a915c6
Sample rate

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sam_grove 0:101a12a915c6 1 /* mbed Example Program
sam_grove 0:101a12a915c6 2 * Copyright (c) 2006-2014 ARM Limited
sam_grove 0:101a12a915c6 3 *
sam_grove 0:101a12a915c6 4 * Licensed under the Apache License, Version 2.0 (the "License");
sam_grove 0:101a12a915c6 5 * you may not use this file except in compliance with the License.
sam_grove 0:101a12a915c6 6 * You may obtain a copy of the License at
sam_grove 0:101a12a915c6 7 *
sam_grove 0:101a12a915c6 8 * http://www.apache.org/licenses/LICENSE-2.0
sam_grove 0:101a12a915c6 9 *
sam_grove 0:101a12a915c6 10 * Unless required by applicable law or agreed to in writing, software
sam_grove 0:101a12a915c6 11 * distributed under the License is distributed on an "AS IS" BASIS,
sam_grove 0:101a12a915c6 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
sam_grove 0:101a12a915c6 13 * See the License for the specific language governing permissions and
sam_grove 0:101a12a915c6 14 * limitations under the License.
sam_grove 0:101a12a915c6 15 */
sam_grove 0:101a12a915c6 16
sam_grove 0:101a12a915c6 17 #include "mbed.h"
sam_grove 0:101a12a915c6 18
wspec 3:5fc7b56ebe8c 19 // Initialize a pins to perform analog input and digital output functions
sam_grove 0:101a12a915c6 20 AnalogIn ain(A0);
wspec 3:5fc7b56ebe8c 21 //DigitalOut dout(LED1);
sam_grove 0:101a12a915c6 22
sam_grove 0:101a12a915c6 23 int main(void)
sam_grove 0:101a12a915c6 24 {
wspec 3:5fc7b56ebe8c 25 Timer t;
wspec 3:5fc7b56ebe8c 26 int sampleCount = 0;
wspec 3:5fc7b56ebe8c 27 while(true)
wspec 3:5fc7b56ebe8c 28 {
wspec 3:5fc7b56ebe8c 29 t.start();
wspec 3:5fc7b56ebe8c 30 while (sampleCount < 1000) {
wspec 3:5fc7b56ebe8c 31 float r = ain.read();
wspec 3:5fc7b56ebe8c 32 sampleCount++;
wspec 3:5fc7b56ebe8c 33 //printf("Raw ADC Val: %f\n", ain.read());
wspec 3:5fc7b56ebe8c 34 //printf("Voltage Val : %f\n",(ain.read_u16()&0xFFF)*3.3/4095);
sam_grove 0:101a12a915c6 35 }
wspec 3:5fc7b56ebe8c 36 printf("Sample Count: %d in %fs\n",sampleCount, t.read());
wspec 3:5fc7b56ebe8c 37 sampleCount = 0;
wspec 3:5fc7b56ebe8c 38 t.reset();
wspec 3:5fc7b56ebe8c 39 }
sam_grove 0:101a12a915c6 40 }