Fire Dragons

Well during this meeting we have finally come up with a Permanent name
Extend-o-Arm
We have also made more progress with the de-bugging for the code on the motor.
#include // include the servo library
Servo servoMotor; // creates an instance of the servo object to control a servo
Servo servo2;
int analogPin = 0; // the analog pin that the sensor is on
int analogValue = 0; // the value returned from the analog sensor

const byte PIN_BUTTON_SELECT = 2; // Select button is triggered when joystick is pressed

const byte PIN_BUTTON_RIGHT = 3;
const byte PIN_BUTTON_UP = 4;
const byte PIN_BUTTON_DOWN = 5;
const byte PIN_BUTTON_LEFT = 6;

const byte PIN_ANALOG_X = 0;
const byte PIN_ANALOG_Y = 1;
int val;
int val2;
int pos = 0;
void setup() {
Serial.begin(9600);

// Specify each pin connected to a pushbutton as an input.
// Also enable the Arduino’s internal “pull-up” resistors
// for each pushbutton we want to read–this means the shield
// doesn’t need to have resistors on it.
// Note that when a pull-up resistor is used on a pin the
// meaning of the values read are reversed compared to their
// usual meanings:
// * HIGH = the button is not pressed
// * LOW = the button is pressed
pinMode(PIN_BUTTON_RIGHT, INPUT);
digitalWrite(PIN_BUTTON_RIGHT, HIGH);

pinMode(PIN_BUTTON_LEFT, INPUT);
digitalWrite(PIN_BUTTON_LEFT, HIGH);

pinMode(PIN_BUTTON_UP, INPUT);
digitalWrite(PIN_BUTTON_UP, HIGH);

pinMode(PIN_BUTTON_DOWN, INPUT);
digitalWrite(PIN_BUTTON_DOWN, HIGH);

pinMode(PIN_BUTTON_SELECT, INPUT);
digitalWrite(PIN_BUTTON_SELECT, HIGH);

servoMotor.attach(8);
servo2.attach(9);
}

void loop() {
// Print the current values of the inputs (joystick and
// buttons) to the console.
Serial.print(“l:”);
Serial.print(digitalRead(PIN_BUTTON_LEFT));
Serial.print(” “);

Serial.print(“r:”);
Serial.print(digitalRead(PIN_BUTTON_RIGHT));
Serial.print(” “);

Serial.print(“u:”);
Serial.print(digitalRead(PIN_BUTTON_UP));
Serial.print(” “);

Serial.print(“d:”);
Serial.print(digitalRead(PIN_BUTTON_DOWN));
Serial.print(” “);

Serial.print(“x:”);
Serial.print(analogRead(PIN_ANALOG_X));
Serial.print(” “);

Serial.print(“y:”);
Serial.print(analogRead(PIN_ANALOG_Y));
Serial.print(” “);

Serial.print(“s:”);
Serial.print(digitalRead(PIN_BUTTON_SELECT));
Serial.print(” “);

Serial.println();

val = analogRead(PIN_ANALOG_X); // reads the value of the potentiometer (value between 0 and 1023)
val = map(val, 0, 1023, 0, 179); // scale it to use it with the servo (value between 0 and 180)
servoMotor.write(val); // sets the servo position according to the scaled value
delay(15);

val2= digitalRead(PIN_BUTTON_DOWN);
if (val2 == LOW)
{
for(pos = 0; pos< 1000; pos += 2)
{
servo2.write(pos);
delay(7);
}
}
}
Although there are some bugs left I feel that the bugs will be resolved by the end of next week.
We tested the the mounting mechanism that will be used to mount the Mechanical Arm.

That's All

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

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