本帖最后由 水车 于 2015-1-28 18:43 编辑
代码上传,有兴趣的朋友可以做一个玩玩
#include "U8glib.h"
U8GLIB_SSD1306_128X64 u8g(13, 11, 10, 9);
void draw(void) {
u8g.setFont(u8g_font_unifont);
u8g.drawStr(0, 16,"1:");
u8g.setPrintPos(16, 16);
u8g.print(analogRead(A0)*6.6/1024);
u8g.drawStr(48, 16,"V");//1
u8g.setFont(u8g_font_unifont);
u8g.drawStr(64, 16,"2W:");
u8g.setPrintPos(80, 16);
u8g.print(analogRead(A1)*6.6/1024);
u8g.drawStr(112, 16,"V");//2
u8g.setFont(u8g_font_unifont);
u8g.drawStr(0, 32,"3:");
u8g.setPrintPos(16, 32);
u8g.print(analogRead(A2)*6.6/1024);
u8g.drawStr(48, 32,"V");//3
u8g.setFont(u8g_font_unifont);
u8g.drawStr(64, 32,"4:");
u8g.setPrintPos(80, 32);
u8g.print(analogRead(A3)*6.6/1024);
u8g.drawStr(112, 32,"V");//4
u8g.setFont(u8g_font_unifont);
u8g.drawStr(0, 48,"5:");
u8g.setPrintPos(16, 48);
u8g.print(analogRead(A4)*6.6/1024);
u8g.drawStr(48, 48,"V");//5
u8g.setFont(u8g_font_unifont);
u8g.drawStr(64, 48,"6:");
u8g.setPrintPos(80, 48);
u8g.print(analogRead(A5)*6.6/1024);
u8g.drawStr(112, 48,"V");//6
u8g.setFont(u8g_font_unifont);
u8g.drawStr(0, 64,"7:");
u8g.setPrintPos(16, 64);
u8g.print(analogRead(A6)*6.6/1024);
u8g.drawStr(48, 64,"V");//7
u8g.setFont(u8g_font_unifont);
u8g.drawStr(64, 64,"8:");
u8g.setPrintPos(80, 64);
u8g.print(analogRead(A7)*6.6/1024);
u8g.drawStr(112, 64,"V");//8
}
void setup(void) {
}
void loop(void){
u8g.firstPage();
do {
draw();
} while( u8g.nextPage() );
delay(500);
}
|