Skip to content

Instantly share code, notes, and snippets.

View johnwargo's full-sized avatar
🏠
Working from home

John M. Wargo johnwargo

🏠
Working from home
View GitHub Profile
@johnwargo
johnwargo / arduino-to-arduino-pin-state.ino
Created November 1, 2023 11:59
A single sketch that covers both sides of reading an Arduino pin state from another Arduino device/sketch
/**********************************************************
* Arduino to Arduino Pin Status
* Demonstration sketch
***********************************************************/
// =============================================================
// comment out the following line to build the receiver version
// of this sketch.
// =============================================================
#define SENDER
@johnwargo
johnwargo / micfofogger-random-smoke-more-better.ino
Last active October 29, 2023 17:18
An even better version of the Arduino random smoke generator
#define SMOKE_PIN A0
#define MIN_TIME 1000
#define MAX_TIME 5000
bool isSmoking = false;
int timerDuration = 0;
unsigned long startTime;
void setup() {
// configure the output pin to control the smoke generator
@johnwargo
johnwargo / microfogger-random-smoke-better
Last active October 29, 2023 15:45
An better version of the Arduino random smoke generator
#define SMOKE_PIN A0
#define MIN_TIME 1000
#define MAX_TIME 5000
bool isSmoking = false;
int timerDuration = 0;
unsigned long startTime;
void setup() {
// configure the output pin to control the smoke generator
@johnwargo
johnwargo / microfogger-random-smoke.ino
Last active October 29, 2023 15:45
An Arduino random smoke generator
#define SMOKE_PIN A0
#define MIN_SMOKE_TIME 1000
#define MAX_SMOKE_TIME 5000
void setup() {
// configure the output pin to control the smoke generator
pinMode(SMOKE_PIN, OUTPUT);
// Enable the Arduino device's onboard LED
pinMode(LED_BUILTIN, OUTPUT);
}
@johnwargo
johnwargo / mmwave.ino
Created October 25, 2023 23:48
Sample application for testing the DFRobot mmWave Radar - 24GHz Human Presence Detection Sensor
/*!
@file DFRobot_mmWave_Radar.ino
@ Read whether there is people or object moving in the detection range of the sensor.
@ The sensor detection range and output delay time can be configured. Also you can restore the sensor to factory default settings.
@n Experimental phenomenon: When the sensor starts successfully, 0 or 1 will be printed on the serial monitor.
@ 0 means that there is no human or object moving in sensing area, 1 means the oppposite.
@copyright Copyright (c) 2010 DFRobot Co.Ltd (http://www.dfrobot.com)
@licence The MIT License (MIT)
@version V1.0
@date 2023-3-13
@johnwargo
johnwargo / feather_player.ino
Last active August 12, 2024 17:27
ESP32 and the Adafruit Music Maker FeatherWing without Interrupts
// Adafruit Sample Sketch modified to not use Interrupts
// Documented here: https://randomerrors.dev/posts/2023/esp32-and-the-adafruit-music-maker-featherwing/
// Specifically for use with the Adafruit Feather, the pins are pre-set here!
// include SPI, MP3 and SD libraries
#include <SPI.h>
#include <SD.h>
#include <Adafruit_VS1053.h>
@johnwargo
johnwargo / mod-set-env.cmd
Last active May 20, 2021 00:22
Windows Command file for configuring a terminal window for the Moddable and ESP32 SDKs
ECHO OFF
REM set UPLOAD_PORT=COM6
REM Do we have the `VCToolsVersion` environment variable?
IF "%VCToolsVersion%"=="" (
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars32.bat"
pushd %IDF_PATH%
call %IDF_TOOLS_PATH%\idf_cmd_init.bat C:\Python39\ "C:\Program Files\Git\cmd\"
popd
) ELSE (
echo:
@johnwargo
johnwargo / advent-calendar.py
Last active May 19, 2021 19:40
Advent Scheduler
# Advent Scheduler
# By John M. Wargo
# Based on initial work by Jannis Jaeger
import random
# Constants
ADVENT_DAYS = 25
# NAMES = ["Anna", "John", "Elizabeth", "August", "Jannis"]
NAMES = ["Anna", "John", "Elizabeth", "August"]
@johnwargo
johnwargo / encrypt1.py
Last active October 22, 2019 12:17
Python Simple Substitution Cypher
#!/usr/bin/env python
in_str = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ '
out_str = 'jklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghi'
def encrypt1(the_string):
the_result = ''
for x in the_string:
pos = in_str.find(x)
the_result += out_str[pos]
@johnwargo
johnwargo / relay-test.py
Last active January 15, 2024 22:00
Simple Python app for controlling a relay through an GPIO Zero Output device
#!/usr/bin/python
# A simple Python application for controlling a relay board from a Raspberry Pi
# The application uses the GPIO Zero library (https://gpiozero.readthedocs.io/en/stable/)
# The relay is connected to one of the Pi's GPIO ports, then is defined as an Output device
# in GPIO Zero: https://gpiozero.readthedocs.io/en/stable/api_output.html#outputdevice
import sys
import time