/******************************************************************** * Function: void pureDataSetAnalog(unsigned char data[]) * Input: unsigned char data[] * Output: None * Overview: This function takes an array of size 3, which contains * data encoded in a MIDI type of format, and uses it to * set Analog values (10 bits) to Pins on the PIC. In this * array the first byte, or data[0] gives information about * the port and pin to address. data[1] contains the Most * Significant byte (bits 9 and 8), while data[2] contains * the Less Significant byte (bits 0 - 7). * Refer to PINGUINO_PD_INTERFACE.xls for details on the * messaging format. * Note: None *******************************************************************/ void pureDataSetAnalog(unsigned char data[]){ int channel = data[0] - SET_ANALOG_VALUE; double setpoint; #if defined(PIC32_PINGUINO) || defined(PIC32_PINGUINO_OTG) switch (channel){ case 0:// PWM 0 setpoint = (256*data[1])+data[2]; analogwrite(D0, setpoint); break; case 1:// PWM 1 setpoint = (256*data[1])+data[2]; analogwrite(D1, setpoint); break; case 2:// PWM 2 setpoint = (256*data[1])+data[2]; analogwrite(D2, setpoint); break; case 3:// PWM 3 setpoint = (256*data[1])+data[2]; analogwrite(LED2, setpoint); break; } #endif }
/** * Move forward */ void DCMotorBot::moveForward() { analogwrite(mE1, mSpeed); analogWrite(mE2, mSpeed); delay(mDelay); digitalWrite(mI1, HIGH); digitalWrite(mI2, LOW); digitalWrite(mI3, HIGH); digitalWrite(mI4, LOW); }