Sunpak AP-200W Arduino Hack (Part 3)

Well today I started to edit the sketch that will control the firmware for the Sunpak AP-200W. I have made progress. I have full control of motors and the LEDs’. I’m trying to get the IR sensors to work, but can’t seem to decide whether or not it should be controlled by IR or push buttons or even serial communication. Right now all this arduino sketch is doing is tilting and panning. Next version will implement button presses and Ir signals (Remote).

Sunpak AP200W.ino

/*Sunpak AP-200W Arduino Firmware
written by: Daniel Frausto
https://danielfrausto.wordpress.com
January 18,2016
*/
int test = 0;
const int motorPin = 12;

const int motor2APin = 5;
const int motor2BPin = 6;
const int motor1APin = 7;
const int motor1BPin = 8;

int wait = 200;

int ledPin = 13;
int buttonPin = 2;
boolean currentState = LOW;//stroage for current button state
boolean lastState = LOW;//storage for last button state
boolean ledState = LOW;//storage for the current state of the LED (off/on)
void setup() {
pinMode(buttonPin, INPUT_PULLUP);//this time we will set the pin as INPUT
pinMode(ledPin, OUTPUT);
pinMode(motorPin, OUTPUT);
pinMode(motor2APin, OUTPUT);
pinMode(motor2BPin, OUTPUT);
pinMode(motor1APin, OUTPUT);
pinMode(motor1BPin, OUTPUT);
Serial.begin(9600);//initialize Serial connection
}

void loop() {
currentState = digitalRead(buttonPin);
if (currentState == LOW && lastState == HIGH) {
delay(1);
if (test == 0) {
test = 1;
Serial.print(test);
}
else {
test = 0;
Serial.print(test);
}
if (test == 0) {
}
}
lastState = currentState;
if (test == 0) {
pwrOFF();
}
if (test == 1) {
pwrON();
}

}

void pwrON()
{
digitalWrite(ledPin, HIGH);
Serial.print(“On”);
Serial.print(‘\n’);
delay(500);
Serial.print(“Still On….”);
Serial.print(‘\n’);

digitalWrite(motorPin, HIGH);

tiltUP();
delay(wait);
tiltSTOP();

//tiltDOWN();
//delay(wait);
//tiltSTOP();
delay(2000);
}

void pwrOFF()
{

digitalWrite(ledPin, LOW);
Serial.print(“OFF”);
Serial.print(‘\n’);
digitalWrite(motorPin, LOW);
digitalWrite(motor1APin, LOW);
digitalWrite(motor1BPin, LOW);

}

Controls.ino

void tiltUP()
{
digitalWrite(motor1APin, HIGH);
digitalWrite(motor1BPin, LOW);

}
void tiltDOWN()
{
digitalWrite(motor1APin, LOW);
digitalWrite(motor1BPin, HIGH);
}

void tiltSTOP()
{
digitalWrite(motor1APin, LOW);
digitalWrite(motor1BPin, LOW);
}

void tiltBRAKE()
{
digitalWrite(motor1APin, HIGH);
digitalWrite(motor1BPin, HIGH);
}

void panUP()
{
digitalWrite(motor1APin, HIGH);
digitalWrite(motor1BPin, LOW);

}
void panDOWN()
{
digitalWrite(motor1APin, LOW);
digitalWrite(motor1BPin, HIGH);
}

void panSTOP()
{
digitalWrite(motor1APin, LOW);
digitalWrite(motor1BPin, LOW);
}

void panBRAKE()
{
digitalWrite(motor1APin, HIGH);
digitalWrite(motor1BPin, HIGH);
}

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s