Skip to content

Instantly share code, notes, and snippets.

View futureshocked's full-sized avatar

Peter Dalmaris futureshocked

View GitHub Profile
@futureshocked
futureshocked / 04.20_-_Grove_analog_light_sensor.ino
Created July 30, 2019 00:52
This sketch demonstrates how to use the Grove analog light sensor.
/* 04.020 - Grove analog light sensor
This sketch demonstrates how to use the Grove analog light sensor.
The analog light sensor is an analog device. It outputs a voltage
level that depends on the intensity of ambient light.
Upload this sketch and start the Serial monitor (you can also use
the serial plotter). Wave your hand over the sensor and notice the
change in the output displayed in the monitor.
@futureshocked
futureshocked / 04.10_-_Grove_temperature_sensor.ino
Last active July 30, 2019 00:51
This sketch read the voltage of a Grove temperature sensor and calculates the temperature in degrees C.
/* 04.010 - Grove temperature sensor (Temperature Sensor V1.1/1.2)
*
This sketch read the voltage of a Grove temperature sensor and
calculates the temperature in degrees C.
The temperature sensor is an analog sensor.
Components
----------
@futureshocked
futureshocked / 03.40_-_Grove_rotary_potentiometer.ino
Last active July 30, 2019 00:49
This sketch demonstrates how to use the Grove rotary potentiometer.
/* 03.040 - Grove rotary potentiometer
*
This sketch demonstrates how to use the Grove rotary potentiometer.
The momentary button is an analog device (i.e. it outputs a voltage
level that depends on the position of the knob).
Components
----------
@futureshocked
futureshocked / 03.30_-_Grove_touch_sensor.ino
Last active July 30, 2019 00:37
This sketch demonstrates how to use the Grove touch sensor. The touch sensor is a digital device (i.e. it can be "on" or "off" only).
/* 03.030 - Grove touch sensor
This sketch demonstrates how to use the Grove touch sensor.
The touch sensor is a digital device (i.e. it can be "on" or "off" only).
Components
----------
@futureshocked
futureshocked / 03.20_-_Grove_momentary_button.ino
Last active July 30, 2019 00:37
This sketch demonstrates how to use the Grove momentary button. The momentary button is a digital device (i.e. it can be "on" or "off" only).
/* 03.020 - Grove momentary button
*
This sketch demonstrates how to use the Grove momentary button.
The momentary button is a digital device (i.e. it can be "on" or "off" only).
Components
----------
@futureshocked
futureshocked / robertscode.ino
Created July 24, 2019 22:35
an exit button that opens a door
// Define interfaces
#define LED_PIN 26 // —>|–[R]—3v3
#define RELAY_PIN 33
#define BUTTON_PIN 25 // —./.—-0V
// Define Timings
#define LED_ACTIVE_ON 0.2 // Flashing when relay output is active
#define LED_ACTIVE_OFF 0.2 // Time in seconds
#define LED_IDLE_ON 12 // On with short turn off when idle
#define LED_IDLE_OFF 0.5
#define RELAY_INTERVAL 6 // duration relay operates in seconds
@futureshocked
futureshocked / parser.ino
Created July 24, 2019 07:02
Simple URL parser
void setup() {
Serial.begin(9600);
while (!Serial)
{}
// put your setup code here, to run once:
String str = "GET /?led06=1";
int led_index = str.indexOf("led");
int equal_index = str.indexOf("=");
@futureshocked
futureshocked / ESP32_timer_interrupt_change_dureation.ino
Created July 20, 2019 05:46
ESP32 timer interrupts, how to change duration in the loop.
const byte LED_GPIO = 2;
volatile int interruptCounter; // When this is not zero, we'll take a reading from the sensor
// The interrupt service routine will increment it.
// When the sensor is read, this variable is decremented.
volatile int blinkCounter = 0;
// The hardware timer pointer
hw_timer_t * timer = NULL;
@futureshocked
futureshocked / 101_datalogger
Created July 1, 2019 00:22
Arduino 101 datalogger example
// Written by Peter Dalmaris.
// This is an example of how to record data from the Arduino 101 accelerometer to an SD card
// Part of a demonstration for the Arduino Bootcamp for Teachers Extension Project
#include <SPI.h>
#include <SD.h>
#include "CurieIMU.h"
const int chipSelect = 4;
@futureshocked
futureshocked / spiffs.ino
Last active April 18, 2019 23:15
An example gist
#include "FS.h"
#include "SPIFFS.h"
// a change
/* You only need to format SPIFFS the first time you run a
test or else use the SPIFFS plugin to create a partition
https://github.com/me-no-dev/arduino-esp32fs-plugin */
#define FORMAT_SPIFFS_IF_FAILED true