MCP4018 sample

Dependencies:   AQM0802 MCP4018 mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 //**********************
00002 // potension registor with 7bits
00003 // MCP4018 sample for mbed
00004 //
00005 // (C)Copyright 2014 All rights reserved by Y.Onodera
00006 // http://einstlab.web.fc2.com
00007 //**********************
00008 #include "mbed.h"
00009 #include "AQM0802.h"
00010 #include "MCP4018.h"
00011 
00012 #if defined(TARGET_LPC1768)
00013 I2C i2c(p28,p27);
00014 #endif
00015 // for TG-LPC11U35-501
00016 #if defined(TARGET_LPC11U35_501)
00017 I2C i2c(P0_5,P0_4);
00018 #endif
00019 // for Nucleo
00020 #if defined(TARGET_NUCLEO_F401RE)
00021 I2C i2c(D14,D15);
00022 #endif
00023 AQM0802 lcd(i2c);
00024 MCP4018 mcp4018(i2c);
00025 
00026 
00027 int main() {
00028     
00029     char msg[10];
00030     unsigned char i;
00031     
00032     while(1){
00033         for(i=0;i<0x80;i++){
00034             mcp4018.put(i);
00035             sprintf(msg, "%5dOhm" , 10000/127*i+75 );
00036             lcd.locate(0,0);
00037             lcd.print(msg);
00038             wait(1);
00039         }
00040     }
00041 
00042 }
00043 
00044