Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
main.cpp
00001 /* 00002 Read analog channel from MCP3201 with SPI interface and send it to the serial interface. 00003 */ 00004 00005 #include "mbed.h" 00006 #include "mcp3201.h" 00007 00008 #define ADC_SCALE_VALUE 3.3/4096 00009 00010 Serial pc(USBTX, USBRX); // tx, rx 00011 00012 int main() 00013 { 00014 pc.printf("Analog read test from MCP3201.\n"); 00015 00016 while(1) 00017 { 00018 float r=(float)ReadAnalogMCP3201() * ADC_SCALE_VALUE; // show value in volts. 00019 pc.printf("AD channel value: %4.2f Volts.\r\n", r); 00020 pc.printf(" Press any key to get new sample...\r\n\r\n"); 00021 char c = pc.getc(); 00022 } 00023 } 00024 00025 00026 00027
Generated on Thu Jul 14 2022 17:55:45 by
