This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Taken from https://forum.arduino.cc/index.php?topic=116094.15 | |
// "Here's my code to set up timer 1 " | |
// dynamic frequency generator | |
// for timer2 | |
#include <avr/io.h> | |
#include <avr/interrupt.h> | |
unsigned long frequency = 1000000 ; // in hertz | |
void setup(){ | |
pinMode(9,1); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const SensorName = "bme280"; | |
const Location = "duren_seribu"; | |
const Influx = require("influx"); | |
const SerialPort = require("serialport"); | |
const port = new SerialPort("/dev/ttyUSB0"); | |
const parser = new SerialPort.parsers.Readline(); | |
const influx = new Influx.InfluxDB({ | |
host: "localhost", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Wire.h> | |
#include <Adafruit_Sensor.h> | |
#include <Adafruit_BME280.h> | |
#define BME_SCK 13 | |
#define BME_MISO 12 | |
#define BME_MOSI 11 | |
#define BME_CS 10 | |
#define SEALEVELPRESSURE_HPA (1013.25) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Calculate distance between two points | |
float distanceCoordinates(float flat1, float flon1, float flat2, float flon2) { | |
// Variables | |
float dist_calc=0; | |
float dist_calc2=0; | |
float diflat=0; | |
float diflon=0; | |
// Calculations |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float getPressure(int raw) { | |
// raw 0-1023, get from analogRead(); | |
// 0.004887585532746823 is from 5v/1023 | |
// General info: | |
// range of voltage reading is 0v-5v | |
// the sensor outputs MPV to (MPV + 4.692v), while the range is (0.133v - 0.204v - 0.274v) to (4.826v - 4.896v - 4.966v) | |
// each KPa is 20mV or 0.02V | |
float voltage = raw * 0.004887585532746823; | |
// Typical MPV is 0.204v@20KPa | |
// Maximum pressure is 250KPa |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float getPressure(int raw) { | |
// raw 0-4095, get from analogRead(); | |
// 0.001221001221001221 is from 5v/4095 | |
// General info: | |
// range of voltage reading is 0V-5v | |
// the sensor outputs 0V or +ZPO to (0v or ZPO)+4.5V, while the range is 4.587v - 4.7v - 4.813v | |
// each KPa is 6.4mV or 0.0064V | |
float voltage = raw * 0.001221001221001221; | |
// Initializing pressure variable as float | |
float pressure = 0.0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float getPressure(int raw) { | |
// raw 0-1023, get from analogRead(); | |
// 0.004887586 is from 5v/1023 | |
// General info: | |
// range of voltage reading is 0V-5v | |
// the sensor outputs 0V or +ZPO to (0v or ZPO)+4.5V, while the range is 4.587v - 4.7v - 4.813v | |
// each KPa is 6.4mV or 0.0064V | |
float voltage = raw * 0.004887586; | |
// Initializing pressure variable as float | |
float pressure = 0.0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <avr/io.h> | |
#include <util/delay.h> | |
int main(void) | |
{ | |
pinMode(3, OUTPUT); // output pin for OCR2B, this is Arduino pin number | |
// In the next line of code, we: | |
// 1. Set the compare output mode to clear OC2A and OC2B on compare match. | |
// To achieve this, we set bits COM2A1 and COM2B1 to high. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function toRadian(num) { | |
return num * (Math.PI / 180); | |
} | |
function toDegree(num) { | |
return num * (180 / Math.PI); | |
} | |
// North is 0 degree, South is 180 degree | |
function getHorizontalBearing(fromLat, fromLon, toLat, toLon, currentBearing) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Ring { | |
constructor(...data) { | |
this.position = 0; | |
if (data instanceof Array) { | |
this.data = data[0]; | |
return; | |
} | |
this.data = data; | |
} |