Skip to content

Instantly share code, notes, and snippets.

@greed9
greed9 / sketch_robot_code.ino
Last active July 19, 2025 22:51
Robot code
// hacked from: https://lastminuteengineers.com/drv8833-arduino-tutorial/
// Define the control inputs
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
@greed9
greed9 / sketch_reaction_time.ino
Last active July 8, 2025 20:27
Simple reaction timer app using switch and interrupts
// *****************************************
// Reaction timer using interrupt
// *****************************************
#define BUTTON_PIN 2
#define LED_PIN 8
// This must be declared volatile since it is accessed from
// the ISR and from loop()
//https://en.wikipedia.org/wiki/Volatile_(computer_programming)
static volatile int isr_counter = 0 ;
@greed9
greed9 / sketch_button_press_proto.ino
Last active July 7, 2025 18:50
Incomplete starter sketch for interrupt/debounce demo
// *****************************************
// Fill in the missing parts of this sketch
// Does not currently compile
// *****************************************
#define BUTTON_PIN /* ? */
#define LED_PIN /* ?*/
// This must be declared volatile since it is accessed from
// the ISR and from loop()
//https://en.wikipedia.org/wiki/Volatile_(computer_programming)
@greed9
greed9 / sketch_touch_switch.ino
Last active July 1, 2025 14:04
Arduino touch switch using the Touchy library
// Arduino "No hardware" touch switch
// Based on https://github.com/todbot/TouchyTouch
#include "TouchyTouch.h"
#define STATUS_LED 4
#define SENSE_PIN 12
const int touch_pin = SENSE_PIN;
// Install as TouchyTouch library in Arduino.
TouchyTouch touches ;
@greed9
greed9 / sketch_hbridge_starter.ino
Created June 23, 2025 19:00
Incomplete sketch to control DC motor speed via H-Bridge and potentiometer
// hacked from: https://lastminuteengineers.com/drv8833-arduino-tutorial/
// Define the control inputs
#define MOT_A1_PIN 6
#define MOT_A2_PIN 5
void setup(void)
{
// Set all the motor control inputs to OUTPUT
pinMode(MOT_A1_PIN, OUTPUT);
@greed9
greed9 / sketch_simple_recv.ino
Created June 16, 2025 15:15
Receive command chars sent via IR Remote Protocol
// Headers for sd1306 display
/* Based on code Written by Limor Fried/Ladyada for Adafruit Industries,
with contributions from the open source community.
BSD license, check license.txt for more information
All text above, and the splash screen below must be
included in any redistribution.
**************************************************************************/
#include <SPI.h>
#include <Wire.h>
@greed9
greed9 / sketch_ir_sender.ino
Created June 16, 2025 15:11
Send characters via IR Remote protocol
/*
* TinySender.cpp
*
* Example for sending using TinyIR. By default sends simultaneously using all supported protocols
* To use a single protocol, simply delete or comment out all unneeded protocols in the main loop
* Program size is significantly reduced when using a single protocol
* For example, sending only 8 bit address and command NEC codes saves 780 bytes program memory and 26 bytes RAM compared to SimpleSender,
* which does the same, but uses the IRRemote library (and is therefore much more flexible).
*
*
@greed9
greed9 / sketch_test_display_starter.ino
Created June 2, 2025 23:24
Starter Sketch for Light Meter
/* Based on code Written by Limor Fried/Ladyada for Adafruit Industries,
with contributions from the open source community.
BSD license, check license.txt for more information
All text above, and the splash screen below must be
included in any redistribution.
**************************************************************************/
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
@greed9
greed9 / ArduinorReadPotStarter.uno
Created May 25, 2025 17:34
Starter Sketch for Flicker Fusion A/D project
/*
AnalogReadSerial
Reads an analog input on pin 0, prints the result to the Serial Monitor.
Graphical representation is available using Serial Plotter (Tools > Serial Plotter menu).
Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.
This example code is in the public domain.
https://docs.arduino.cc/built-in-examples/basics/AnalogReadSerial/
@greed9
greed9 / sketch_tach_starter.ino
Last active May 20, 2025 16:59
Arduino Starter sketch for Tach
// Read and process hall effect sensor for use as tach
// See https://www.allelcoelec.com/blog/A3144-Hall-Effect-Sensor-Pinout,Alternatives,and-Applications.html for hookup
#define HALL_EFFECT_PIN 2
int sensor_value = 0 ; // output from hall sensor, low for detect
void setup() {
// put your setup code here, to run once
Serial.begin( 115200 ) ;