Skip to content

Instantly share code, notes, and snippets.

@matt448
matt448 / Speedometer_HMI.ino
Created June 1, 2017 15:47
Arduino based speedometer using a Nextion HMI Display
#include "Nextion.h"
const int lightPin = 0;
const int hardwareCounterPin = 5;
const int samplePeriod = 1000; //in milliseconds
const float pulsesPerMile = 4000;
const float convertMph = pulsesPerMile/3600;
unsigned int count;
float mph;
@matt448
matt448 / Speedometer_TM1637.ino
Created January 13, 2016 02:30
Digital speedometer using a TM1637 type display
// Matthew McMillan
// @matthewmcmillan
// http://matthewcmcmillan.blogspot.com
//
// Digital speedometer that uses a TM1637 type display
//
// Code is written for an Arduino UNO
//
// VSS on car connects to digital pin 5
// CLK on display to digital pin 3
@matt448
matt448 / hx711_calibration.ino
Last active March 13, 2023 16:56
HX711 Calibration for Arduino
/*
Started with example code written by Nathan Seidle from SparkFun Electronics and added
LCD output with gram and ounce values.
Setup your scale and start the sketch WITHOUT a weight on the scale
Once readings are displayed place the weight on the scale
Press +/- or a/z to adjust the calibration_factor until the output readings match the known weight
Arduino pin 6 -> HX711 CLK
Arduino pin 5 -> HX711 DOUT
/////////////////////////////////////////////////////////////////////
// This is a simple example of sending CAN messages with 29bit id's
//
// https://matthewcmcmillan.blogspot.com
// Twitter: @matthewmcmillan
//
#include "mcp_can.h"
#include <SPI.h>
/////////////////////////////////////////////////////////////////////
// This is a simple example of sending CAN messages with 11bit id's
//
// https://matthewcmcmillan.blogspot.com
// Twitter: @matthewmcmillan
//
#include "mcp_can.h"
#include <SPI.h>
@matt448
matt448 / serialtest.py
Last active July 16, 2020 19:45
Python script to test the CAN data sent by the Trinket CAN to UART converter
#!/usr/bin/python
##########################################
# https://matthewcmcmillan.blogspot.com
# Twitter: @matthewmcmillan
#
# For the most up to date version of this file see:
# https://github.com/matt448/Digital_Dash_v2/blob/master/serialtest.py
#
@matt448
matt448 / trinket_can_to_uart.ino
Last active August 29, 2015 14:14
A CAN Bus to Uart Converter using an Adafruit Pro Trinket, MCP2515 and a MCP2562.
////////////////////////////////////////////
//
// Trinket Pro CAN Bus to UART Converter
//
// https://matthewcmcmillan.blogspot.com
// Twitter: @matthewmcmillan
//
// For the most up to date version of this file see:
// https://github.com/matt448/Digital_Dash_v2/blob/master/arduino_code/trinket_can_to_uart.ino
//
@matt448
matt448 / canbus_start.sh
Created October 19, 2014 20:29
Script to start can bus interface on a Beagle Bone Black
#!/bin/bash
re='^[0-9]+$'
if ! [[ $1 =~ $re ]] ; then
echo -e "ERROR: Can bus bitrate not a number or a value wasn't entered.\n\nPlease enter a speed in Kbit/s\n\n Example: canbus_start.sh 100\n Speeds: 100,125,250,500\n" >&2; exit 1
fi
echo Bitrate: ${1}Kbit/s
sudo modprobe can
sudo modprobe can-dev
@matt448
matt448 / dcan1_dmesg_output.txt
Created October 19, 2014 18:34
Output from dmesg when enabling dcan1 on a Beagle Bone Black
root@bone:~# dmesg | tail -n 15
[1190326.609897] gadget: high-speed config #1: Multifunction with RNDIS
[1199448.966162] bone-capemgr bone_capemgr.9: part_number 'BB-DCAN1', version 'N/A'
[1199448.966337] bone-capemgr bone_capemgr.9: slot #9: generic override
[1199448.966382] bone-capemgr bone_capemgr.9: bone: Using override eeprom data at slot 9
[1199448.966430] bone-capemgr bone_capemgr.9: slot #9: 'Override Board Name,00A0,Override Manuf,BB-DCAN1'
[1199448.968166] bone-capemgr bone_capemgr.9: slot #9: Requesting part number/version based 'BB-DCAN1-00A0.dtbo
[1199448.968223] bone-capemgr bone_capemgr.9: slot #9: Requesting firmware 'BB-DCAN1-00A0.dtbo' for board-name 'Override Board Name', version '00A0'
[1199448.969684] bone-capemgr bone_capemgr.9: slot #9: dtbo 'BB-DCAN1-00A0.dtbo' loaded; converting to live tree
[1199448.970118] bone-capemgr bone_capemgr.9: slot #9: #2 overlays
@matt448
matt448 / BB-DCAN1-00A0.dts
Last active August 29, 2015 14:07
Device tree overlay to enable dcan1 on a Beagle Bone Black
/dts-v1/;
/plugin/;
/ {
compatible = "ti,beaglebone", "ti,beaglebone-black";
/* identification */
part-number = "dcan1pinmux";
fragment@0 {