Skip to content

Instantly share code, notes, and snippets.

View jenschr's full-sized avatar

Jens Chr Brynildsen jenschr

View GitHub Profile
//////////////////////////////////////////////////////////////////
//©2011 bildr
//Released under the MIT License – Please reuse change and share
//Simple code for the ADXL335, prints calculated orientation via serial
//////////////////////////////////////////////////////////////////
//Analog read pins
const int xPin = 0;
const int yPin = 1;
const int zPin = 2;
void setup()
{
Serial.begin(9600);
pinMode(13, OUTPUT);
}
void loop()
{
/* send everything received from the hardware uart to usb serial & vv */
if (Serial.available() > 0) {
@jenschr
jenschr / MAX30102.cpp
Created November 2, 2018 11:54
Simple (incomplete) example of how to detect beats from data given by a MAX30102 sensor
unsigned long sensorValue = particleSensor.getIR();
if ( sensorValue > 50000)
{
if ( usePlotter )
{
Serial.println(sensorValue); //Send raw data to plotter
} else {
int diff = lastSensorValue - sensorValue;
if ( diff > 80 ) // we may have a beat!
{
@jenschr
jenschr / HC06_change_name.ino
Created November 9, 2018 13:37
Simple code snippet to test BT serial + change the name of your HC-06 BT module
// Open Serial Monitor after uploading and make sure it's set to 57600baud
// Check that you get "OK" in the serial monitor after "BT ready?"
// Remember to turn on CR + Newline nat the bottom of the Serial Monitor
// Type in "AT+NAME:yourName" in input-field of your Serial monitor
SoftwareSerial mySerial(10, 11); // RX, TX
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(57600);
/*******************************************************************************
* Copyright (c) 2015 Thomas Telkamp and Matthijs Kooijman
* Copyright (c) 2018 Terry Moore, MCCI
*
* Permission is hereby granted, free of charge, to anyone
* obtaining a copy of this document and accompanying files,
* to do whatever they want with them without any restriction,
* including, but not limited to, copying, modification and redistribution.
* NO WARRANTY OF ANY KIND IS PROVIDED.
*
@jenschr
jenschr / apa102.cpp
Last active January 5, 2019 20:55
APA102 on STM32F070F6
/*
* Simplified code for running APA-102 on STM32
* (or most any other platform by replacing the
* sendRaw-method with platform SPI calls)
*/
#define NUMBER_OF_LEDS 46 // Define number of LEDs in the chain
#define COLORS_PER_LED 3 // Define number of colors we store
const int bufferLength = NUMBER_OF_LEDS*3;
#include <OneWire.h>
int DS18S20_Pin = 2; //DS18S20 Signal pin on digital 2
//Temperature chip i/o
OneWire ds(DS18S20_Pin); // on digital pin 2
void setup(void) {
Serial.begin(9600);
}
@jenschr
jenschr / Fona example file modified for use with Teensy
Last active June 2, 2019 01:01
Adafruit Fona modifications for Teensy 3.1, updated for latest lib + simplified
/*
Replace the first lines in your FONATest example file with the lines below. It's basically just changing from SoftwareSerial to HardwareSerial + changed pins to match the Teensy.
*/
#include <SoftwareSerial.h>
#include <HardwareSerial.h>
#include "Adafruit_FONA.h"
#define FONA_RX 1
#define FONA_TX 0
#define FONA_RST 4
@jenschr
jenschr / HiGrow_server.ino
Last active July 22, 2019 08:53
Arduino example for using the HiGrow board based on ESP32 as a server, so you can check in on your plant to see how it's doing
/*
* Arduino example for using the HiGrow board based on ESP32 as a server, so you can check in on your plant to see how it's doing
*
* Details on the hardware and how to use it can be found on:
* http://flashgamer.com/blog/comments/higrow-esp32-moisture-and-temperature-sensor#capacitive
*/
#include "DHT.h"
#include <WiFi.h>