Skip to content

Instantly share code, notes, and snippets.

View futureshocked's full-sized avatar

Peter Dalmaris futureshocked

View GitHub Profile
@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 / 06_distance_sensor.ino
Created October 1, 2019 04:50
06. Ultrasonic distance sensor HC-SR04 demo sketch (Oscilloscopes for Busy People)
/* 06. Ultrasonic distance sensor HC-SR04 demo sketch
*
* This sketch calculates the distance between the HC-SR04 sensor and
* an object directly infront of it.
*
* To see the trigger and echo waveforms with your oscilloscope,
* connect CHA to the trigger and CHB to the echo pins.
*
* Set up edge trigger to CHA, and set it to 1V (or there about).
*
@futureshocked
futureshocked / 05_button_reaction.ino
Created October 1, 2019 04:27
05. Arduino button oscilloscope demo sketch (Oscilloscopes for Busy People)
/* 05. Arduino button oscilloscope demo sketch
*
* Use this sketch to see a button press as a waveform event in the
* oscilloscope.
*
* Connect CHA of the oscilloscope to the button signal pin.
*
* Connect CHB to the anode of an LED.
*
* Set the scope to 5us time scale and 200mV voltage scale.
@futureshocked
futureshocked / 07_PWM.ino
Created October 1, 2019 04:53
07. Arduino PWM oscilloscope demo sketch (Oscilloscopes for Busy People)
/* 07. Arduino PWM oscilloscope demo sketch
*
* Use this sketch to experiment with the measurement of a PWM waveform
* on an oscilloscope.
*
* Connect CHA of the oscilloscope to the anode of the LED.
*
* Use a potentiometer to control the duty cycle.
*
* Set triggering to Auto, and start the experiment.
@futureshocked
futureshocked / LJ - 07.30 - sine_wave_DAC0.lua
Created April 26, 2021 04:45
This script creates a rudimentary sine wave on DAC0.
--[[
LJ - 07.30 - sine_wave_DAC0.lua
This script creates a rudimentary sine wave on DAC0.
Components
----------
- LabJack T4
- Oscilloscope
@futureshocked
futureshocked / flight_controller.ino
Created March 7, 2022 01:18
This script implements a flight controller joystick for my X-Flight simulator. Works with an Arduino Micro or A-Star 32U4 Mini
// Requires Arduino Joystick Library https://github.com/MHeironimus/ArduinoJoystickLibrary
#include <Joystick.h>
const int8_t sw_1 = 18;
const int8_t sw_2 = 4;
const int8_t sw_3 = 6;
//Joystick_ Joystick;
Joystick_ Joystick(JOYSTICK_DEFAULT_REPORT_ID,
JOYSTICK_TYPE_JOYSTICK, 4, 0,
@futureshocked
futureshocked / sensor.ino
Created September 4, 2019 03:05
One of Peter's sketches in which he uses JSON to send data to Adafruit IO and receive, parse the response using ArduinoJSON.
void refresh_readings() {
float f_temperature;
float f_humidity;
float f_pressure;
float f_altitude;
digitalWrite(LED_PIN, HIGH);
postCounter++; // New post, increase the post counter
@futureshocked
futureshocked / BME280.py
Created February 25, 2021 22:27
MicroPython driver for the BME280 sensor on the Raspberry Pi Pico
from machine import I2C
import time
# BME280 default address.
BME280_I2CADDR = 0x76
# Operating Modes
BME280_OSAMPLE_1 = 1
BME280_OSAMPLE_2 = 2
BME280_OSAMPLE_4 = 3
@futureshocked
futureshocked / Arduino_ticker.ino
Created September 7, 2021 08:10
Test Peter's four 8x8 LED matrix with Arduino PRo Mini PCB
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Max72xxPanel.h>
int pinCS = 10; // Attach CS to this pin, DIN to MOSI and CLK to SCK (cf http://arduino.cc/en/Reference/SPI )
int numberOfHorizontalDisplays = 4;
int numberOfVerticalDisplays = 1;
byte button_1 = 5;
byte button_2 = 4;
@futureshocked
futureshocked / led-pm-expreriment.ino
Created June 29, 2020 05:26
This sketch will blink the LED at GPIO5 once per second and then go to sleep.
// Written by Peter Dalmaris from Tech Explorations.
// Used to find out how long an ESP32 can last on a LiPo battery.
// This sketch will blink the LED at GPIO5 once per second and
// store the number of blinks in an EEPROM location.
// In between blinks, the ESP32 goes to sleep.
#include "EEPROM.h"
#include <DeepSleepScheduler.h>
#ifdef ESP32