Go Down

Topic: Looking to hire a programmer (Read 799 times) previous topic - next topic

beltfedweapon

I am not looking to learn how to program at this time, i am not looking for guidance on how to program. I am looking to pay someone $50. to basically add a millis command (I think) to a program for me. This is what I have so far

Code: [Select]
// These constants won't change:
const int analogPin = A0;    // pin that the camera PWR sensor is attached to
const int ledPin = 12;       // pin that the camera PWR button is attached to
const int threshold = 475;   // an arbitrary threshold level that's in the range of the analog input

void setup() {
  // initialize the Camera PWR button as an output:
  pinMode(ledPin, OUTPUT);
  // initialize serial communications:
  Serial.begin(9600);
}

void loop() {
  // read the value of the camera PWR:
  int analogValue = analogRead(analogPin);

  // if the analog value is too low, "Press" the PWR button:
  if (analogValue < threshold) {
    Serial.println("Pressing PWR in 2 seconds; then delay for 5 seconds");
    delay(2000);
    digitalWrite(ledPin, HIGH);
    delay(500);
    digitalWrite(ledPin, LOW);
    delay(5000);
  }
  else {
    digitalWrite(ledPin,LOW);
  }

  // print the analog value:
  Serial.println(analogValue, DEC);

}


This seems to work so far. It monitors a camera and it turns the camera on if it shuts off. I would like to make it press a REC button after it sees that the camera is on. I have a photoresistor connected to a blinking LED on the front of the camera so it knows if the camera is recording or not. I have the photoresistor connected to a 10k resistor and I can monitor the blinking LED light using this code

Code: [Select]
int lightPin = A1;  //define a pin for Photo resistor
int ledPin=11;     //define a pin for LED

void setup()
{
    Serial.begin(9600);  //Begin serial communcation
    pinMode( ledPin, OUTPUT );
}

void loop()
{
    Serial.println(analogRead(lightPin)); //Write the value of the photoresistor to the serial monitor.
    analogWrite(ledPin, analogRead(lightPin)/4);  //send the value to the ledPin. Depending on value of resistor
                                                //you have  to divide the value. for example,
                                                //with a 10k resistor divide the value by 2, for 100k resistor divide by 4.
   delay(10); //short delay for faster response to light.
}


I would like to combine these 2 codes and when it needs to rec have it send a signal for a few milliseconds on a desired output (I have a 5 volt relay to do the mechanical part) I believe this would only take someone who knows what they are doing about 20 minutes. I would like to skype with someone just to show them exactly what needs to be done and then i believe it to be relatively simple. I'm sure i have left a lot out but I will answer any questions you may have on skype. This is just to initially give a brief description of what I am asking. Please msg me if you are interested.

johnwasser

I already wrote code like this to manage two cameras in a high-altitude balloon. Had the same LDR to watch the Record light.  Also had two wires into the guts of the camera to detect power, turn on power, and activate the Record button.

The Arduino was also logging GPS coordinates, RTC, and temperatures.  Each module has a setup function and a loop function so that could share the Arduino's time.

Code: [Select]


//  Fault flags
extern const unsigned int Cam1_fault;
extern const unsigned int Cam2_fault;
extern unsigned int Faults;

const int APIN_CAMERA_1_RECORD_LIGHT = 0;
const int DPIN_CAMERA_1_POWER = 3; // Ground for a second to turn on power
const int DPIN_CAMERA_1_RECORD = 4; // Reads HIGH if power is on. Pull LOW to start recording

const int APIN_CAMERA_2_RECORD_LIGHT = 1;
const int DPIN_CAMERA_2_POWER = 5; // Ground for a second to turn on power
const int DPIN_CAMERA_2_RECORD = 6; // Reads HIGH if power is on. Pull LOW to start recording

boolean camera1_is_recording = false;
boolean camera2_is_recording = false;
unsigned long lastCamera1RecordLightTime = 0;
unsigned long lastCamera2RecordLightTime = 0;
unsigned int camera1_minReading = 1023;
unsigned int camera1_maxReading = 0;
unsigned int camera2_minReading = 1023;
unsigned int camera2_maxReading = 0;

// how many milliseconds between grabbing data and logging it. 1000 ms is once a second
#define CAMERA_INTERVAL  5000 // mills between entries (reduce to take more/faster data)
unsigned long LastCameraTime = 0;

void Cameras_setup(void)
{
  // Initialize the cameras
  InitializeCamera(APIN_CAMERA_1_RECORD_LIGHT, DPIN_CAMERA_1_POWER, DPIN_CAMERA_1_RECORD);
  InitializeCamera(APIN_CAMERA_2_RECORD_LIGHT, DPIN_CAMERA_2_POWER, DPIN_CAMERA_2_RECORD);
}

void Cameras_loop(void)
{
  unsigned long currentTime = millis();

  CheckRecordingLight(camera1_is_recording, lastCamera1RecordLightTime, APIN_CAMERA_1_RECORD_LIGHT, camera1_minReading, camera1_maxReading, Cam1_fault);
  CheckRecordingLight(camera2_is_recording, lastCamera2RecordLightTime, APIN_CAMERA_2_RECORD_LIGHT, camera2_minReading, camera2_maxReading, Cam2_fault);

  if (currentTime - LastCameraTime > CAMERA_INTERVAL)
  {
    LastCameraTime = currentTime;
    ManageCamera(camera1_is_recording, lastCamera1RecordLightTime, APIN_CAMERA_1_RECORD_LIGHT, DPIN_CAMERA_1_POWER, DPIN_CAMERA_1_RECORD, Cam1_fault);
    ManageCamera(camera2_is_recording, lastCamera2RecordLightTime, APIN_CAMERA_2_RECORD_LIGHT, DPIN_CAMERA_2_POWER, DPIN_CAMERA_2_RECORD, Cam2_fault);
  }
}


void  InitializeCamera(int APIN_RECORDING, int DPIN_POWER, int DPIN_RECORD)
{
  pinMode(DPIN_POWER, OUTPUT);
  digitalWrite(DPIN_POWER,LOW);
  pinMode(DPIN_RECORD, INPUT);
}

void CheckRecordingLight(boolean &isRecording, unsigned long &lastRecordLightTime,int APIN_RECORDING, 
unsigned int &minReading, unsigned int &maxReading, unsigned int faultFlag)
{
  int reading = analogRead(APIN_RECORDING);
  if (reading < minReading)
      minReading = reading;
  if (reading > maxReading)
      maxReading = reading;
  unsigned int avgReading = (minReading + maxReading) / 2;
 
  boolean recordLight = (reading < avgReading) && (minReading != maxReading);

  if (recordLight)
  {
    lastRecordLightTime = millis();
    isRecording = true;
  }

  // If the light has been off for more than two seconds
  if (millis() - lastRecordLightTime > 2000)
  {
    isRecording = false;
    Faults |= faultFlag;
  }
}

void  ManageCamera(boolean &isRecording, unsigned long &lastRecordLightTime, int APIN_RECORDING, int DPIN_POWER, int DPIN_RECORD, unsigned int faultFlag)
{
  // Every 10 seconds...

  // Check that power is on
  pinMode(DPIN_RECORD, INPUT);
  if (digitalRead(DPIN_RECORD) == LOW)
  {
    // Power is off.
    Faults |= faultFlag;
    //  Turn the power on
    // Serial.println("Power is off. Turning on.");
    digitalWrite(DPIN_POWER, HIGH);
    delay(500);
    digitalWrite(DPIN_POWER,LOW);
    // Check again in 10 seconds
  }
  else
  {
    // Power is on.  Make sure we are recording
    if (isRecording)
    {
      Faults &= ~faultFlag;
    }
    else
    {
      // Serial.println("Power is ready. Start recording.");
      digitalWrite(DPIN_RECORD, LOW);
      pinMode(DPIN_RECORD, OUTPUT); // Pull the line low
      delay(500);
      pinMode(DPIN_RECORD, INPUT); // Let it float again
    }
  }
}
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

beltfedweapon

This is that same balloon project. We lost contact with the last one shortly after launch. I have since went out and got my HAM radio license. This time we are using http://www.aprs.org/ as a tracking device. We where looking to launch this Sunday (Weather permitting). The code above you have posted is much too advance for me to figure out, especially in regards to how I would wire it. This launch has the same cameras with the same wiring coming out of them but I wouldn't begin to knmow where to put transistor/resistors or anything else for that code. The APRS device will be doing the logging and altititude so the only thing we really need on this one is the camera controls.

Go Up