Skip to content
Snippets Groups Projects
Commit 31d360f2 authored by 13035516's avatar 13035516
Browse files

first commit

parent 96e31cc5
No related merge requests found
# Swap
[._]*.s[a-v][a-z]
[._]*.sw[a-p]
[._]s[a-v][a-z]
[._]sw[a-p]
# Session
Session.vim
# Temporary
.netrwhist
*~
# Auto-generated tag files
tags
# Ignored directories
Output/
Data/
Input/
Test/
/*****************************************************************************************************
* PIN LAYOUT
* This file is used by other classes to define the pins used for the hardware.
*****************************************************************************************************/
#ifndef CONFIGURATION_H
#define CONFIGURATION_H
#include <Arduino.h>
/* Runtime Configuration */
#define DELAY 0
/* Debug Options */
#define DEBUG 0
/* Serial Options */
#define BAUDRATE 115200
#define PING '1'
/* =================================== */
/* Pin layout */
/* =================================== */
/* Motor Pins */
#define VIBRATION_PIN 28
/* Potentiometer Pins */
#define POT0_PIN A3
/* LED Pins */
#define LED_BUILTIN 13
/* =================================== */
/* Resolution */
/* =================================== */
#define ADC_RES 1024
/* Buffer len */
#define DEFAULT_BUFFER_LEN 2560
#define COMBINATION_LEN 3
#endif
#include "Potentiometer.h"
Potentiometer::Potentiometer() {
pin = POT0_PIN;
pot_val = 0;
}
Potentiometer::Potentiometer(uint16_t _pin) {
pin = _pin;
pot_val = 0;
}
Potentiometer::~Potentiometer() {}
void Potentiometer::Set_Pin(uint16_t _pin) {
pin = _pin;
}
void Potentiometer::Set_Pin_Mode() {
pinMode(pin, INPUT);
}
uint16_t Potentiometer::Get_Pin() {
return pin;
}
void Potentiometer::Read_Potentiometer() {
pot_val = analogRead(pin);
}
int Potentiometer::Get_Reading() {
return pot_val;
}
#ifndef _POTENTIOMETER_H_
#define _POTENTIOMETER_H_
#include <stdio.h>
#include "Configuration.h"
class Potentiometer {
public:
Potentiometer();
Potentiometer(uint16_t _pin);
~Potentiometer();
void Set_Pin(uint16_t _pin);
void Set_Pin_Mode();
uint16_t Get_Pin();
void Read_Potentiometer();
int Get_Reading();
private:
uint16_t pin;
int pot_val;
};
#endif
#include "VibrationMotor.h"
VibrationMotor::VibrationMotor() {
pin = VIBRATION_PIN;
amplitude = 0;
}
VibrationMotor::VibrationMotor(uint16_t _pin, int _amplitude) {
pin = _pin;
amplitude = _amplitude;
}
VibrationMotor::~VibrationMotor() {}
void VibrationMotor::Set_Pin(uint16_t _pin) {
pin = _pin;
}
void VibrationMotor::Set_Pin_Mode() {
pinMode(pin, OUTPUT);
}
uint16_t VibrationMotor::Get_Pin() {
return pin;
}
void VibrationMotor::Set_Amplitude(int _adc) {
// read in between 0 and 1023, analogWrite values from 0 to 255
amplitude = _adc / 4;
}
int VibrationMotor::Get_Amplitude() {
return amplitude;
}
void VibrationMotor::Drive_Motor() {
analogWrite(pin, amplitude);
}
#ifndef _VIBRATIONMOTOR_H_
#define _VIBRATIONMOTOR_H_
#include <stdio.h>
#include "Configuration.h"
class VibrationMotor {
public:
VibrationMotor();
VibrationMotor(uint16_t _pin, int _amplitude);
~VibrationMotor();
void Set_Pin(uint16_t _pin);
uint16_t Get_Pin();
void Set_Pin_Mode();
void Set_Amplitude(int _amplitude);
int Get_Amplitude();
void Drive_Motor();
private:
uint16_t pin;
int amplitude;
};
#endif
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment