miniblip analog example

Dependencies:   mbed

Fork of AnalogIn-HelloWorld by Mbed

Committer:
pighixxx
Date:
Thu Nov 26 09:25:10 2015 +0000
Revision:
2:7734a904c531
Parent:
0:101a12a915c6
Analog example with miniblix

Who changed what in which revision?

UserRevisionLine numberNew contents of line
pighixxx 2:7734a904c531 1 // miniblip analog in
pighixxx 2:7734a904c531 2
pighixxx 2:7734a904c531 3 // photoresistor: P0_23
pighixxx 2:7734a904c531 4 // external analogs: P0_15, P0_14, P0_13, P0_12, P0_11
sam_grove 0:101a12a915c6 5
sam_grove 0:101a12a915c6 6 #include "mbed.h"
sam_grove 0:101a12a915c6 7
sam_grove 0:101a12a915c6 8 // Initialize a pins to perform analog input and digital output fucntions
pighixxx 2:7734a904c531 9 AnalogIn ain(P0_23);
pighixxx 2:7734a904c531 10
pighixxx 2:7734a904c531 11 Serial pc(USBTX, USBRX);
sam_grove 0:101a12a915c6 12
sam_grove 0:101a12a915c6 13 int main(void)
sam_grove 0:101a12a915c6 14 {
sam_grove 0:101a12a915c6 15 while (1) {
sam_grove 0:101a12a915c6 16 // print the percentage and 16 bit normalized values
pighixxx 2:7734a904c531 17 pc.printf("Perc: %3.3f%%\n", ain.read()*100.0f);
pighixxx 2:7734a904c531 18 pc.printf("Norm: 0x%04X \n", ain.read_u16());
sam_grove 0:101a12a915c6 19 wait(0.2f);
sam_grove 0:101a12a915c6 20 }
sam_grove 0:101a12a915c6 21 }