Front page   Edit Freeze Diff Backup Upload Copy Rename Reload   New List of pages Search Recent changes   Help   RSS of recent changes

Camera Platform Control using Acceleration Sensor

Last-modified: 2012-08-20 (Mon) 00:29:30 (1915d)
Top / Camera Platform Control using Acceleration Sensor

Movie

Devices

Arduino Board

Acceleration Sensor

KXM52-1050

CCD Camera

Keyence CK-300

USB Video Capture

Princeton USB Video Capture Unit PCA-DAV

Code for Arduino

// camera_platform_control1

#include <Servo.h>

Servo rcs[2];
const int rcs_pin[] = { 9, 10 };
int rcs_pos[] = { 0, 0 };

const int accel_pin[] = { 0, 1, 2 };
int accel_val[] = { 0, 0, 0 };

void setup() {
  for (int i = 0; i < 2; i++) {
    rcs[i].attach(rcs_pin[i]);
  }
}

void loop() {
  for (int i = 0; i < 3; i++) {
    accel_val[i] = analogRead(accel_pin[i]);
  }
  
  rcs[0].write(180 - accel_val[0]*0.18);
  rcs[1].write(accel_val[1]*0.18);
  
  delay(50);
}