Completed ready for demo- scan_mux_fun
Dependencies: mbed
Fork of Microprocessors_Template by
main.cpp
- Committer:
- anr41
- Date:
- 2018-02-06
- Revision:
- 2:69ec832f181c
- Parent:
- 1:cff235122df8
- Child:
- 3:eb70e1c75e7f
File content as of revision 2:69ec832f181c:
/******************************************************************************* *EECS397 * *Assignment Name: Lab 3; Scan Mux Fun * *Author(s): Ashley Roberson, Michael Codega * *Purpose: * *Last Modified: February 6, 2018 * *******************************************************************************/ #include "mbed.h" #define NUMCHANNELS 16 Serial pc(USBTX, USBRX); char input; void scanChannel(float *voltages); float channelData[NUMCHANNELS]; 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 scanChannel(channelData); pc.printf("Printing for Scan_Mux_Fun.\n"); for(int i = 0; i < NUMCHANNELS; i++) { //print out pc.printf("The channel data for %d is: %f\n", i, channelData[i] * 3.3f); } } } void scanChannel(float *voltages) { for(int i = 0; i < NUMCHANNELS; i++) { // scan channels muxSel = i; wait(0.00001); voltages[i] = muxOut.read(); } }