Completed ready for demo- scan_mux_fun
Dependencies: mbed
Fork of Microprocessors_Template by
main.cpp
- Committer:
- anr41
- Date:
- 2018-02-03
- Revision:
- 1:cff235122df8
- Parent:
- 0:24202d4eadef
- Child:
- 2:69ec832f181c
File content as of revision 1:cff235122df8:
/******************************************************************************* *EECS397 * *Assignment Name: Lab 3; Scan Mux * *Author(s): Ashley Roberson, Michael Codega * *Purpose: Scans all 16 channels, stores those analog values in an array, and * then prints values in array to serial console with each channel * labeled when a key from the serial console is pressed. * *Last Modified: February 3, 2018 * *******************************************************************************/ #include "mbed.h" Serial pc(USBTX, USBRX); char input; float channelData[16]; BusOut muxSel(PC_6, PB_15, PB_13, PB_12); AnalogIn muxOut(PB_1); int main(void) { while(1) { // wait for an input character to be rx'ed while(!pc.readable()) { ; // do nothing } input = pc.getc(); // business logic: // scan 16 channels, store those values in array // print array for(int i = 0; i < 16; i++) { // scan channels muxSel = i; wait(0.00001); channelData[i] = muxOut.read(); } for(int i = 0; i < 16; i++) { //print out pc.printf("The channel data for %d is: %d\n", i, channelData[i]); } } }