Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Appendices

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

1

APPENDIX A

ESTIMATED COST OF THE STUDY


2

APPENDIX B

RESEARCH
GANTT CHART
3

APPENDIX C

PROGRAM OF THE DEVICE

#include <RobotIRremote.h>
#include <RobotIRremoteInt.h>
#include <RobotIRremoteTools.h>
// ****************************** SPI - ADXL345 CONFIGURATION AND
LIBRARY ************************************
#include <Wire.h>
#include <Adafruit_SSD1306.h> // header files
#include <Adafruit_GFX.h>
#include <SparkFun_ADXL345.h> // SparkFun ADXL345 Library -
SENSOR Libraries
// ****************************** I2C - 0.9 inch OLED DISPLAY
CONFIGURATION AND LIBRARY ************************************
#define READINGS_NUMBER 10
#define DELAY_TIME 10
#define OLED_ADDR 0x3C // Address of Slave - default per OLED
Module
Adafruit_SSD1306 display(-1); // -1 = no reset pin
#if (SSD1306_LCDHEIGHT != 64) //
#error("Height incorrect, please fix Adafruit_SSD1306.h!");
#endif

// set variables
float DEG = 0.00; // final degrees na mogawas sa screen
float DEG2 = 0.00; // final degreed

float accfront = 0.00;


float accside = 0.00;

float data = 0.00;


float data2 = 0.00;

float deg = 0.00;


float deg2 = 0.00;

float accZ = 0.00;


float denum = 0.00;
float denum2 = 0.00;
4

ADXL345 adxl = ADXL345(10); // USE FOR SPI


COMMUNICATION, ADXL345(CS_PIN);

void setup()
{

//Serial.begin(9600); // Start the serial terminal

display.begin(SSD1306_SWITCHCAPVCC, OLED_ADDR); //
Initialize OLED
display.clearDisplay();
display.display();

adxl.powerOn(); // Power on the ADXL345

adxl.setRangeSetting(16); // Give the range settings


// Accepted values are 2g, 4g, 8g or 16g
// Higher Values = Wider Measurement Range
// Lower Values = Greater Sensitivity

adxl.setSpiBit(0); // Configure the device to be in 4 wire SPI


mode when set to '0' or 3 wire SPI mode when set to 1
// Default: Set to 1
// SPI pins on the ATMega328: 11, 12 and 13 as
reference in SPI Library
}
void loop()
{
int front,side,z; // set variables that will hold adxl reading
adxl.readAccel(&front, &side, &z);

accfront = (front+1.5)/32; //Calibrated values for each data gathered.


accside = (side-.5)/32;
accZ = (z+1.5)/32;

// Formula for calculating front and back tilt angle


denum = sqrt(pow(accfront,2)+pow(accZ,2));
data = accside/denum;
deg = atan(data);
DEG = deg*57.3;

// Formula for calculating side tilt angle


denum2 = sqrt(pow(accside,2)+pow(accZ,2));
5

data2 = accfront/denum2;
deg2 = atan(data2);
DEG2 = deg2*57.3;

// Display values on OLED


display.clearDisplay();
display.setTextSize(3);
display.setTextColor(WHITE);
display.setCursor(20,5);
display.print(DEG2);
display.setCursor(20,36);
display.setTextSize(3);
display.print(DEG);
display.display();
delay(500);
}

You might also like