Christian Lerche
/
MCP4822_HelloWorld
Runs through some voltages
main.cpp@0:9921e2758bd8, 2011-01-21 (annotated)
- Committer:
- Lerche
- Date:
- Fri Jan 21 10:58:43 2011 +0000
- Revision:
- 0:9921e2758bd8
Example program for MCP4822
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Lerche | 0:9921e2758bd8 | 1 | #include "mbed.h" |
Lerche | 0:9921e2758bd8 | 2 | #include "MCP4822.h" |
Lerche | 0:9921e2758bd8 | 3 | |
Lerche | 0:9921e2758bd8 | 4 | MCP4822 MCP(p5, p7, p8); // MOSI, SCLK, nCS |
Lerche | 0:9921e2758bd8 | 5 | |
Lerche | 0:9921e2758bd8 | 6 | int main() { |
Lerche | 0:9921e2758bd8 | 7 | while(1){ |
Lerche | 0:9921e2758bd8 | 8 | MCP.writeA(1650); // 1650 V out |
Lerche | 0:9921e2758bd8 | 9 | MCP.writeB(1650); // Same on B output |
Lerche | 0:9921e2758bd8 | 10 | wait(5); |
Lerche | 0:9921e2758bd8 | 11 | MCP.writeA(0); // Zero v out |
Lerche | 0:9921e2758bd8 | 12 | MCP.writeB(0); // Same on B |
Lerche | 0:9921e2758bd8 | 13 | wait(5); |
Lerche | 0:9921e2758bd8 | 14 | MCP.writeA(3300); // Guess what? |
Lerche | 0:9921e2758bd8 | 15 | MCP.writeB(3300); // 3.3 V |
Lerche | 0:9921e2758bd8 | 16 | wait(5); |
Lerche | 0:9921e2758bd8 | 17 | } // Return to beginning. |
Lerche | 0:9921e2758bd8 | 18 | } |