Skip to content

Instantly share code, notes, and snippets.

View StuffAndyMakes's full-sized avatar

StuffAndyMakes StuffAndyMakes

View GitHub Profile
@StuffAndyMakes
StuffAndyMakes / Automotive Stepper TMC2208 Test.c
Created January 25, 2025 17:45
Automotive Stepper TMC2208 Test
/*
* Testing little dashboard steppers with a TMC2208 stepper driver (all from Amazon)
* Stepper: https://a.co/d/4dKBO58
* Driver: https://a.co/d/bby0QgZ
*
* Tested on an Arduino UNO clone.
*
* Code will run the stepper to the maximum clockwise, then back to the 0 stop.
* It will then pick random steps to jump to (clockwise or counterclockwise)
* and do that indefinitely.
@StuffAndyMakes
StuffAndyMakes / millis-blink.c
Last active January 6, 2025 18:29
millis() Blink
@StuffAndyMakes
StuffAndyMakes / delay-blink.c
Last active January 6, 2025 18:30
millis() > delay() on Arduino
@StuffAndyMakes
StuffAndyMakes / SimpleLEDController.cpp
Created July 13, 2015 14:44
Example usage for StuffAndyMakes.com Simple LED Controller shift register breakout board
#include "Arduino.h"
#define data 8
#define clk 9
#define oe 7
#define rst 6
void pulseClock() {
digitalWrite(clk, HIGH);
digitalWrite(clk, LOW);
@StuffAndyMakes
StuffAndyMakes / SAM_LED_Controller.cpp
Created July 13, 2015 13:11
Example usage for StuffAndyMakes.com Simple LED Controller shift register breakout board
#include "mbed.h"
DigitalOut data(PTB9);
DigitalOut clk(PTB8);
DigitalOut oe(PTB10);
DigitalOut rst(PTB11);
Serial out(PTA2, PTA1);
// CRC-8 - based on the CRC8 formulas by Dallas/Maxim
// code released under the therms of the GNU GPL 3.0 license
// Found at: http://www.leonardomiliani.com/en/2013/un-semplice-crc8-per-arduino/
uint8_t SerialPacket::_crc8(const uint8_t *data, uint8_t len) {
uint8_t crc = 0x00;
while (len--) {
uint8_t extract = *data++;
for (uint8_t tempI = 8; tempI; tempI--) {
uint8_t sum = (crc ^ extract) & 0x01;
crc >>= 1;
@StuffAndyMakes
StuffAndyMakes / FreeRAM.cpp
Created May 22, 2015 16:02
Quick free available RAM function for Arduino/AVR
// found at https://learn.adafruit.com/memories-of-an-arduino/measuring-free-memory
int freeRam () {
extern int __heap_start, *__brkval;
int v;
return (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval);
}
@StuffAndyMakes
StuffAndyMakes / SerialPacketReceiveSnippet.cpp
Last active August 29, 2015 14:21
Snippet showing SerialPacket receiving
typedef struct {
uint8_t device;
uint8_t command;
uint32_t value;
uint64_t serial;
uint8_t ack;
} Command;
void SenderApplication::didReceiveGoodPacket(SerialPacket *p) {
Serial.println("Got good packet!");