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.
main.cpp
- Committer:
- ryood
- Date:
- 2017-06-30
- Revision:
- 2:492523fce75e
- Parent:
- 0:0e326a52b0f4
- Child:
- 3:88504897a2e8
File content as of revision 2:492523fce75e:
#include "mbed.h"
#include "mcp3008.h"
#define SPI_CLOCK (2000000)
SPI spiM(SPI_MOSI, SPI_MISO, SPI_SCK);
MCP3008 mcp3008_0(&spiM, D10);
MCP3008 mcp3008_1(&spiM, D9);
int main()
{
spiM.frequency(SPI_CLOCK);
uint16_t v0[8];
uint16_t v1[8];
for (;;) {
for (int i = 0; i < 8; i++) {
v0[i] = mcp3008_0.read_input_u16(i);
v1[i] = mcp3008_1.read_input_u16(i);
}
printf("Device0\t");
for (int i = 0; i < 8; i++) {
printf("%4d\t", v0[i]);
}
for (int i = 0; i < 8; i++) {
printf("%4d\t", v1[i]);
}
printf("\r\n");
wait(0.2);
}
}