Tambi\u00e9n he utilizado un machete que he encontrado en la web de hackinglab para convertir los datos.<\/a><\/p>\nEl c\u00f3digo completo es:<\/p>\n
[sourcecode language=\u00bbpy\u00bb]<\/p>\n
\/\/ POWER SUPPLY LCD
\n\/\/
\n\/\/ Author: walii.es walterleonardo@gmail.com
\n\/\/
\n#define LCD_RS 8
\n#define LCD_E 9
\nuchar text1;
\nuchar text2;
\nvoid lcdPulseEnable() {
\ndigitalWrite(LCD_E, HIGH);
\ndelayMicroseconds(1);
\ndigitalWrite(LCD_E, LOW);
\ndelayMicroseconds(1);
\n}
\nvoid lcdWriteNibble(uchar c){
\nint i;
\nfor(i=0; i<4; i++){
\ndigitalWrite(4+i, (c >> i) & 0x01);
\n}
\nlcdPulseEnable();
\n}
\nvoid lcdWriteByte(uchar c, int mode) {
\ndigitalWrite(LCD_RS, mode);
\nlcdWriteNibble(c >> 4);
\nlcdWriteNibble(c);
\n}
\nvoid lcdSendControl(uchar c) {
\nlcdWriteByte(c, LOW);
\n}
\nvoid lcdSendData(uchar c) {
\nlcdWriteByte(c, HIGH);
\n}
\nvoid lcdSetAddress(uchar line, uchar column) {
\nlcdSendControl( 0x80 + 0x40 * (line – 1) + (column – 1));
\n}
\nvoid lcdPrint(char *string) {
\nint i;
\nfor( i=0; string[i]; i++) {
\nlcdSendData(string[i]);
\n}
\n}
\nvoid Int2Char(char *Result, unsigned int ToConvert)
\n{
\nuchar Digit[5];
\nint c;
\nunsigned int H1,H2,H3;
\nH1=ToConvert;
\nH2=0;
\nH3=10000;
\nfor (c=4;c>=0;c–)
\n{
\nDigit<\/p>\n
[c][\/c]<\/p>\n
= H1\/H3;
\nH1=ToConvert-Digit<\/p>\n
[c][\/c]<\/p>\n
*H3-H2;
\nH2=H2+Digit<\/p>\n
[c][\/c]<\/p>\n
*H3;
\nH3=H3\/10;
\nResult[4-c]=Digit<\/p>\n
[c][\/c]<\/p>\n
+48;
\n}
\n}
\nvoid lcdInit() {
\nint i;
\npinMode(LCD_E, OUTPUT);
\ndigitalWrite(LCD_E, LOW);
\npinMode(LCD_RS, OUTPUT);
\ndigitalWrite(LCD_RS, LOW);
\nfor(i = 4; i < 8; i++) {
\npinMode(i, OUTPUT);
\n}
\ndelay(20);
\nlcdWriteNibble(0x03);
\ndelayMicroseconds(1);
\nlcdWriteNibble(0x03);
\ndelayMicroseconds(1);
\nlcdWriteNibble(0x02);
\ndelayMicroseconds(200);
\nlcdSendControl(0x28); \/\/ 4 Bit, 2 Lines
\ndelayMicroseconds(1);
\nlcdSendControl(0x0C); \/\/ Display On
\ndelayMicroseconds(1);
\nlcdSendControl(0x01); \/\/ Clear display
\ndelay(2);
\nlcdSendControl(0x02); \/\/ Cursor home
\ndelay(2);
\n}
\nuchar line1[] = "Pinguino MADRID";
\nuchar line2[] = "Voltimetro walii.es";
\nuchar line3[] = "walii.es";
\nuchar line4[] = "Voltaje Consumo";
\nuchar volts[] = "mV ";
\nuchar amper[] = "mA ";
\nuchar Amp[5];
\nuchar Volt[5];
\nvoid setup() {
\nlcdInit();
\n}
\nvoid loop() {
\nint amp1;
\nint amp2;
\nunsigned int amp0;
\nunsigned int volt1;
\namp1=analogRead(13);
\namp2=analogRead(15);
\namp1=amp1\/16*78;
\namp2=amp2\/16*78;
\nif (amp1>amp2){
\namp0 = amp1-amp2;
\n}
\nelse{
\namp0 = 0;
\n}
\nInt2Char(Amp,amp0);
\nvolt1=(float)analogRead(16); \/\/QUITAR ESTE FLOAT SI SE QUIERE COMPILAR EN B9.01
\nvolt1=volt1\/16*78;
\nInt2Char(Volt,volt1);
\nlcdSendControl(0x01);
\ndelay(2);
\nlcdSendControl(0x02);
\ndelay(2);
\nlcdSetAddress(1, 1);
\nlcdPrint(line1);
\nlcdSetAddress(2, 1);
\nlcdPrint(Volt);
\nlcdSetAddress(2, 6);
\nlcdPrint(volts);
\nlcdSetAddress(2, 9);
\nlcdPrint(Amp);
\nlcdSetAddress(2, 14);
\nlcdPrint(amper);
\ndelay(1000);
\nlcdSendControl(0x01);
\ndelay(2);
\nlcdSendControl(0x02);
\ndelay(2);
\nlcdSetAddress(1, 1);
\nlcdPrint(line4);
\nlcdSetAddress(2, 1);
\nlcdPrint(Volt);
\nlcdSetAddress(2, 6);
\nlcdPrint(volts);
\nlcdSetAddress(2, 9);
\nlcdPrint(Amp);
\nlcdSetAddress(2, 14);
\nlcdPrint(amper);
\ndelay(1000);
\n}<\/p>\n
[\/sourcecode]<\/p>\n
NOTA: para que el c\u00f3digo funcione en la ultima version de PINGUINO la beta9.01 <\/strong>\r\nnecesitamos quitar el (float) de la linea 111, utilizada para el analogRead... <\/strong>\r\nque parece que hay un problema en la nueva version con las variables... <\/strong>\r\nlo voy a estudiar... esta version la hab\u00eda compilado en el IDE 8 por eso <\/strong>\r\nno vi el inconveniente... lo siento.<\/strong><\/pre>\n","protected":false},"excerpt":{"rendered":"Me puse a pensar en reconstruir mi fuente de alimentaci\u00f3n y se me ocurri\u00f3 que porque no hacerla con PING\u00dcINO\u2026 Ten\u00eda un LCD de 2×16\u2026…<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[],"_links":{"self":[{"href":"https:\/\/pinguino.walii.es\/index.php?rest_route=\/wp\/v2\/posts\/223"}],"collection":[{"href":"https:\/\/pinguino.walii.es\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pinguino.walii.es\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pinguino.walii.es\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/pinguino.walii.es\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=223"}],"version-history":[{"count":13,"href":"https:\/\/pinguino.walii.es\/index.php?rest_route=\/wp\/v2\/posts\/223\/revisions"}],"predecessor-version":[{"id":226,"href":"https:\/\/pinguino.walii.es\/index.php?rest_route=\/wp\/v2\/posts\/223\/revisions\/226"}],"wp:attachment":[{"href":"https:\/\/pinguino.walii.es\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=223"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pinguino.walii.es\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=223"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pinguino.walii.es\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=223"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}