{"id":628,"date":"2012-04-19T22:20:45","date_gmt":"2012-04-19T21:20:45","guid":{"rendered":"http:\/\/pinguino.walii.es\/?p=628"},"modified":"2012-04-19T22:20:45","modified_gmt":"2012-04-19T21:20:45","slug":"control-pinguino-from-macosx","status":"publish","type":"post","link":"https:\/\/pinguino.walii.es\/?p=628","title":{"rendered":"Control PINGUINO from MACosx"},"content":{"rendered":"

Hi\u00a0good morning,\u00a0this\u00a0is another project\u00a0involving\u00a0PINGUINO\u00a0mac\u00a0and I understand that\u00a0this is very\u00a0restrictive,\u00a0but today\u00a0with the\u00a0Hackintosh anyone can have a\u00a0MAC\u00a0OSX,\u00a0I say this from me experience.
\nThis is a\u00a0very\u00a0basic\u00a0application\u00a0that controls both\u00a0the\u00a0digital and\u00a0the\u00a0analog gates\u00a0of a PINGUINO 18fx550, whether\u00a0we use the\u00a0serial port\u00a0option\u00a0as\u00a0USB with CDC,and also\u00a0with the\u00a0bluetooth\u00a0module tested\u00a0in previous\u00a0posts.<\/p>\n

Need two\u00a0parts, a\u00a0program\u00a0for MAC,<\/p>\n

\"\"<\/a><\/p>\n

DOWNLOAD LINK<\/a><\/p>\n

and the second a code\u00a0for the PINGUINO,this code\u00a0is very comprehensive\u00a0and provides\u00a0for communications from any platform,\u00a0works like code, with two\u00a0digits\u00a0(by now we do not need more\u00a0),\u00a0the first digit\u00a0identifies\u00a0the door and\u00a0the second the treatment, to the\u00a0digital\u00a0port identifies\u00a0a 0=LOW\u00a0and 1=HIGH, but for\u00a0analog ports\u00a0I have decided\u00a0that 3\u00a0may give the\u00a0reading order.
\nSo if\u00a0we want to read\u00a0analog\u00a0port\u00a013 which\u00a0correspond to \u00abAN0\u00bb and\u00a0we would execute \u00ab03\u00bb us back\u00a0the digital value\u00a0between\u00a00 and\u00a01023 of\u00a0this port.
\nIn the other hand\u00a0we want to raise\u00a0the output of the\u00a0digital\u00a0port \u00ab0\u00bb then\u00a0we send\u00a0to turn ON \u00ab01\u00bb and \u00ab00\u00bb to turn OFF.
\nSounds\u00a0complicate but it is understood\u00a0when applied
\nIf you\u00a0want a\u00a0help, we will sent \u00ab9\u00bb with\u00a0any other number, it returns\u00a0a help.<\/p>\n

[sourcecode language=\u00bbpy\u00bb]
\n\/*Project IPHONE, IPAD & MAC talk with PINGUINO walii.es*\/
\n\/\/You need send number port 0 to 7 and status 0 or 1
\n\/\/for anoalogic port you will check port an0 to an7 and need set status in 3
\n\/\/for help you need set 9 in the value0
\n#define LENGTH 3
\n#define RUNLED PORTAbits.RA4
\nint rxBuffer[16];
\nint rxIndex = 0;
\nint i,value1,value0,value,value0a;
\nvoid setup() {
\n Serial.begin(9600);
\n for (i=0;i<8;i++) { \/\/servos conections
\n pinMode(i,OUTPUT);
\n digitalWrite(i,LOW); \/\/ fixe un niveau 0 sur les sorties
\n }
\n}<\/p>\n

void loop (){
\n if (Serial.available() > 0) {
\n\/\/if(rxIndex==0) Serial.printf("Captured first value \\n\\r");
\n\/\/if(rxIndex==1) Serial.printf("Captured Second value \\n\\r");
\n rxBuffer[rxIndex]=Serial.read();
\nrxIndex=rxIndex+1;
\n if(rxIndex==LENGTH){
\n value0=rxBuffer[0]-48;
\n value0a=rxBuffer[0]-35;
\n value1=rxBuffer[1]-48;
\n if(value1<2)
\n {
\n Serial.printf("Port: %d,",value0);
\n Serial.printf("Status: %d\\n\\r",value1);
\n if( value1==0 ) {
\n digitalWrite(value0,LOW);
\n } else if (value1==1) {
\n digitalWrite(value0,HIGH);
\n }
\n }
\n if(value1==3){
\n value=analogRead(value0a);
\n Serial.printf("Reading port %d -> An%d value= %d\\n\\r",value0a,value0,value);
\n }
\n if(value0==9) Serial.printf("You need send number port 0 to 7 and status 0 or 1\\n\\r for analogic port you will check port an0 to an7 \\n\\r and need set status in 3 for help you need set 9 in the value0\\r\\n");
\n rxIndex = 0;
\n \/\/if (rxIndex==0) Serial.printf("Waiting …\\n\\r");
\n}<\/p>\n

}
\n delay(10);
\n}
\n[\/sourcecode]<\/p>\n