Hi good morning, this is another project involving PINGUINO mac and I understand that this is very restrictive, but today with the Hackintosh anyone can have a MAC OSX, I say this from me experience.
This is a very basic application that controls both the digital and the analog gates of a PINGUINO 18fx550, whether we use the serial port option as USB with CDC,and also with the bluetooth module tested in previous posts.
Need two parts, a program for MAC,
and the second a code for the PINGUINO,this code is very comprehensive and provides for communications from any platform, works like code, with two digits (by now we do not need more ), the first digit identifies the door and the second the treatment, to the digital port identifies a 0=LOW and 1=HIGH, but for analog ports I have decided that 3 may give the reading order.
So if we want to read analog port 13 which correspond to «AN0» and we would execute «03» us back the digital value between 0 and 1023 of this port.
In the other hand we want to raise the output of the digital port «0» then we send to turn ON «01» and «00» to turn OFF.
Sounds complicate but it is understood when applied
If you want a help, we will sent «9» with any other number, it returns a help.
[sourcecode language=»py»]
/*Project IPHONE, IPAD & MAC talk with PINGUINO walii.es*/
//You need send number port 0 to 7 and status 0 or 1
//for anoalogic port you will check port an0 to an7 and need set status in 3
//for help you need set 9 in the value0
#define LENGTH 3
#define RUNLED PORTAbits.RA4
int rxBuffer[16];
int rxIndex = 0;
int i,value1,value0,value,value0a;
void setup() {
Serial.begin(9600);
for (i=0;i<8;i++) { //servos conections
pinMode(i,OUTPUT);
digitalWrite(i,LOW); // fixe un niveau 0 sur les sorties
}
}
void loop (){
if (Serial.available() > 0) {
//if(rxIndex==0) Serial.printf("Captured first value \n\r");
//if(rxIndex==1) Serial.printf("Captured Second value \n\r");
rxBuffer[rxIndex]=Serial.read();
rxIndex=rxIndex+1;
if(rxIndex==LENGTH){
value0=rxBuffer[0]-48;
value0a=rxBuffer[0]-35;
value1=rxBuffer[1]-48;
if(value1<2)
{
Serial.printf("Port: %d,",value0);
Serial.printf("Status: %d\n\r",value1);
if( value1==0 ) {
digitalWrite(value0,LOW);
} else if (value1==1) {
digitalWrite(value0,HIGH);
}
}
if(value1==3){
value=analogRead(value0a);
Serial.printf("Reading port %d -> An%d value= %d\n\r",value0a,value0,value);
}
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");
rxIndex = 0;
//if (rxIndex==0) Serial.printf("Waiting …\n\r");
}
}
delay(10);
}
[/sourcecode]