My team member left and I have to pick up where he left off. He finished the code for our project (I pasted the code below as well as attached a file) in C and now I have to upload it to and Arduino Mega 2560. I only understand basic C and I am not familiar with the syntax requirements for the Arduino IDE. I assume this section at the top of the code sting call upon libraries (which I am currently learning about):
#include "C:\Users\Hi2yo\MPLABXProjects\CONTROL.X\core\system.h"
#include "C:\Users\Hi2yo\MPLABXProjects\CONTROL.X\core\led.h"
#include "C:\Users\Hi2yo\MPLABXProjects\CONTROL.X\core\resistiveSensors.h"
#include "C:\Users\Hi2yo\MPLABXProjects\CONTROL.X\core\powerDriver.h"
#include "C:\Users\Hi2yo\MPLABXProjects\CONTROL.X\core\co2.h"
#include "C:\Users\Hi2yo\MPLABXProjects\CONTROL.X\core\button.h"
#include "C:\Users\Hi2yo\MPLABXProjects\CONTROL.X\core\usb.h"
#include "C:\Users\Hi2yo\MPLABXProjects\CONTROL.X\core\sdcard.h"
#include "C:\Users\Hi2yo\MPLABXProjects\CONTROL.X\core\dataLog.h"
#include "C:\Users\Hi2yo\MPLABXProjects\CONTROL.X\core\camera.h"
#include "C:\Users\Hi2yo\MPLABXProjects\CONTROL.X\core\dateTime.h"
#include "C:\Users\Hi2yo\MPLABXProjects\CONTROL.X\core\expansion.h"
My question is (for clarification) how do I upload this code onto an Arduino Mega 2560? Is it as simple as downloading these listed libraries, changing the file address for each library in the code, and then copy and pasting everything into the Arduino IDE?
Thanks!
---CODE---
/*
* File: controlProgram.c
* Author: David
*
* Created on November 9, 2016, 2:37 PM
*/
#include "C:\Users\Hi2yo\MPLABXProjects\CONTROL.X\core\system.h"
#include "C:\Users\Hi2yo\MPLABXProjects\CONTROL.X\core\led.h"
#include "C:\Users\Hi2yo\MPLABXProjects\CONTROL.X\core\resistiveSensors.h"
#include "C:\Users\Hi2yo\MPLABXProjects\CONTROL.X\core\powerDriver.h"
#include "C:\Users\Hi2yo\MPLABXProjects\CONTROL.X\core\co2.h"
#include "C:\Users\Hi2yo\MPLABXProjects\CONTROL.X\core\button.h"
#include "C:\Users\Hi2yo\MPLABXProjects\CONTROL.X\core\usb.h"
#include "C:\Users\Hi2yo\MPLABXProjects\CONTROL.X\core\sdcard.h"
#include "C:\Users\Hi2yo\MPLABXProjects\CONTROL.X\core\dataLog.h"
#include "C:\Users\Hi2yo\MPLABXProjects\CONTROL.X\core\camera.h"
#include "C:\Users\Hi2yo\MPLABXProjects\CONTROL.X\core\dateTime.h"
#include "C:\Users\Hi2yo\MPLABXProjects\CONTROL.X\core\expansion.h"
/* This is written by David
*
* +++overall psueducode+++
*
* initialize system
*
* set scanner resolutions
*
* return motor to position 0
*
* scan sample 0
*
* record data 0
*
* write to SD card 0
*
* move motor to position 1
*
* scan sample 1
*
* record data 1
*
* write to SD card 0
*
* move motor to position 2
*
* scan sample 2
*
* record data 2
*
* write to SD card 0
*
* move motor to position 3
*
* scan sample 3
*
* record data 3
*
* write to SD card 0
*
* repeat
*
* +++END+++
*
* +++motor control pseudocode+++
* Position 1:
*
* rotate motor until resistiveSensor Q1 reads 5V
*
* stop motor
*
* Position 2:
*
* rotate motor until resistiveSensor Q1 reads 3.33V
*
* Position 3:
*
* rotate motor until resitiveSensor Q1 reads 1.66V
*
* stop motor
*
* Position 4:
*
* rotate motor until resisitveSensor Q1 reads 0V
*
* stop motor
*
* +++END+++
*
* +++scan pseudocode+++
*
* turn on rumble packs via LEDR control for 5s
*
* turn off rumble packs
*
* turn on spec laser via LEDB controller
*
* turn on scanner clock clock
*
* turn on RST and SHT
*
* turn off RST after 1 clock cycle
*
* turn off SHT after 6 clock cycles
*
* wait 1 clock cycle
*
* turn on DATA
*
* turn off DATA after 1 clock cycle
*
* begin sampling VIDEO for 1s
*
* +++END+++
*
*
* +++revised scan pseudocode+++
*
Initialize expansion slots
Configure EC2 to analog input
Configure EC1, EC3, EC4, EC5, EC6, EC7, EC8 to digital outputs
Initialize clock signal via EC8
digital write a constant signal through EC3 and EC4 to M0 and M1 to determine the output resolution
Digital write HIGH through pins EC1 and EC6 to trigger Reset and Shutter functions
Digital write LOW to complete reset Cycle via EC6
Digital write LOW to complete Shutter cycle via EC1
Digital write HIGH to Data via EC7
Begin to take analog input from EC2
Digital write LOW to Data via EC7
Repeat as needed
* +++END+++
*
*
*/
int motorPosition; //variable for potentiometer
int videoSignal; //variable for data signal
void motorPosition0 () //declared function for motor position 0
{
motorPosition = (int)resistiveSensors.readQ1(); //reads Q1 value and records as a variable
if (motorPosition < 1024);
{
powerDriverA.on(); // turns on motor
while (motorPosition < 1024) //continuously reads sensor values until desired value occurs
{
delay (1);
motorPosition = (int)resistiveSensors.readQ1();
}
powerDriverA.off(); // turns off motor
}
}
void motorPosition1 () //Declared Function for motor position 1
{
motorPosition = (int)resistiveSensors.readQ1(); //reads Q1 value and records as a variable
if (motorPosition < 683);
{
powerDriverB.on(); // turns on motor
while (motorPosition < 683) //continuously reads sensor values until desired value occurs
{
delay(1);
motorPosition = (int)resistiveSensors.readQ1();
}
powerDriverB.off(); // turns off motor
}
if (motorPosition > 683);
{
powerDriverA.on(); // turns on motor
while (motorPosition > 683) //continuously reads sensor values until desired value occurs
{
delay(1);
motorPosition = (int)resistiveSensors.readQ1();
}
powerDriverA.off(); // turns off motor
}
}
void motorPosition3 () //Declared Function for motor position 3
{
motorPosition = (int)resistiveSensors.readQ1(); //reads Q1 value and records as a variable
if (motorPosition < 0);
{
powerDriverB.on(); // turns on motor
while (motorPosition < 0) //continuously reads sensor values until desired value occurs
{
delay(1);
motorPosition = (int)resistiveSensors.readQ1();
}
powerDriverB.off(); // turns off motor
}
if (motorPosition > 0);
{
powerDriverA.on(); // turns on motor
while (motorPosition > 0) //continuously reads sensor values until desired value occurs
{
delay(1);
motorPosition = (int)resistiveSensors.readQ1();
}
powerDriverA.off(); // turns off motor
}
}
void recordData ()
{
dataLog.add ("time", (int)dateTime.get);
dataLog.add ("Absorbtion", videoSignal);
}
void scan ()
{
ledR.dutycycle(50); //engages rumble packs for 5 seconds
delay (5000);
ledR.dutycycle(0); //shuts off rumble packs
ledB.dutycycle(50); //turns on laser
expansion.digitalOut (6,1); //set resolution
expansion.digitalOut (5,0);
expansion.digitalOut (8,0); //begin scanner clock cycle
delay (500);
expansion.digitalOut (10,1);
delay (500);
expansion.digitalOut (10,0);
delay (250);
expansion.digitalOut (3,1); //opens shutter
expansion.digitalOut (8,1); //resets all pixels to 0
delay (250);
expansion.digitalOut (10,0);
delay (250);
expansion.digitalOut (8,0); //ends reset cycle, pixels begin doing things
delay (250);
expansion.digitalOut (10,1);
delay (500);
expansion.digitalOut (10,0);
delay (500);
expansion.digitalOut (10,1);
delay (500);
expansion.digitalOut (10,0);
delay (500);
expansion.digitalOut (10,1);
delay (500);
expansion.digitalOut (10,0);
delay (500);
expansion.digitalOut (10,1);
delay (500);
expansion.digitalOut (10,0);
delay (500);
expansion.digitalOut (10,0);
delay (250);
expansion.digitalOut (3,0); //closes shutter, pixels stop doing things
delay (250);
expansion.digitalOut (10,1);
delay (250);
expansion.digitalOut (10,0);
delay (250);
expansion.digitalOut (9,1); //tells sensor to send data
delay (250);
expansion.digitalOut (10,1); //sensor starts sending data
delay (250);
expansion.digitalOut (9,0); //shuts off data signal, data keeps sending
delay (250);
expansion.digitalOut (10,0);
delay (500);
expansion.digitalOut (10,1);
delay (100);
videoSignal = (int)resistiveSensors.readQ2; //reads video signal and records it as a variable
delay (500);
expansion.digitalOut (10,0); //shuts off sensor and waits 1 second
delay(1000);
ledB.dutycycle(0); //shuts off laser
}
void motorPosition2 () //Declared function for motor position 2
{
motorPosition = (int)resistiveSensors.readQ1() ; //reads Q1 value and records as a variable
if (motorPosition < 342);
{
powerDriverB.on(); // turns on motor
while (motorPosition < 342) //continuously reads sensor values until desired value occurs
{
delay(1);
motorPosition = (int)resistiveSensors.readQ1();
}
powerDriverB.off(); // turns off motor
}
if (motorPosition > 342);
{
powerDriverA.on(); // turns on motor
while (motorPosition > 342) //continuously reads sensor values until desired value occurs
{
delay(1);
motorPosition = (int)resistiveSensors.readQ1();
}
powerDriverA.off(); // turns off motor
}
}
int main(int argc, char** argv)
{
system.init(); //setup code to be run once
usb.init();
sdcard.init();
ledR.init();
ledB.init();
dataLog.init();
resistiveSensors.init();
expansion.init();
powerDriverA.init();
powerDriverB.init();
while (1==1) //actual program to run forever or until power off
{
motorPosition0();
scan();
recordData();
motorPosition1();
scan();
recordData();
motorPosition2();
scan();
recordData();
motorPosition3();
scan();
recordData();
}
}