Skip to content

Instantly share code, notes, and snippets.

@cnc4less
cnc4less / I2C_Adapter.ino
Created August 8, 2021 22:44 — forked from kraftb/I2C_Adapter.ino
USB to I2C Adapter using Arduino
// I2C to USB Adapter using Arduino
// by Bernhard Kraft <[email protected]>
/**
* This sketch can get loaded onto an Arduino to use it as USB to I2C Adapter.
* It uses the Wire library. So take a look at the documentation of the Wire
* libarary about the pins being used as SDA/SCL. For most Arduino boards this
* will be analog input pin 4 for SDA and analog input pin 5 for SCL.
*
* On the USB side the default serial link of the Arduino is used. A protocol
@cnc4less
cnc4less / serialRelayTest.ino
Created June 8, 2021 05:28 — forked from ItKindaWorks/serialRelayTest.ino
A simple Arduino program for controlling an LC Tech serial relay board
/*
serialRelayTest.ino
*/
byte relON[] = {0xA0, 0x01, 0x01, 0xA2}; //Hex command to send to serial for open relay
byte relOFF[] = {0xA0, 0x01, 0x00, 0xA1}; //Hex command to send to serial for close relay
void setup(void){
Serial.begin(9600);

This is a collection of code snippets for various features on the STM8S family microcontrollers (specifically the STM8S003F3). These are written against the STM8S/A SPL headers and compiled using SDCC.

Some of this controller's functions aren't particularly intuitive to program, so I'm dumping samples for future reference here. These are based on the STM8S documentation:

Run at 16MHz

#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
const char* ssid = "..............";
const char* password = "................";
String form = "<form action='led'><input type='radio' name='state' value='1' checked>On<input type='radio' name='state' value='0'>Off<input type='submit' value='Submit'></form>";
String imagepage = "<img src='/led.png'>";
@cnc4less
cnc4less / HowToOTGFast.md
Created October 3, 2018 03:13 — forked from gbaman/HowToOTGFast.md
Simple guide for setting up OTG modes on the Raspberry Pi Zero, the fast way!

###Setting up Pi Zero OTG - The quick way (No USB keyboard, mouse, HDMI monitor needed)
More details - http://blog.gbaman.info/?p=791

For this method, alongside your Pi Zero, MicroUSB cable and MicroSD card, only an additional computer is required, which can be running Windows (with Bonjour, iTunes or Quicktime installed), Mac OS or Linux (with Avahi Daemon installed, for example Ubuntu has it built in).
1. Flash Raspbian Jessie full or Raspbian Jessie Lite onto the SD card.
2. Once Raspbian is flashed, open up the boot partition (in Windows Explorer, Finder etc) and add to the bottom of the config.txt file dtoverlay=dwc2 on a new line, then save the file.
3. If using a recent release of Jessie (Dec 2016 onwards), then create a new file simply called ssh in the SD card as well. By default SSH is

@cnc4less
cnc4less / MassMind.org ENC1 3Wire ReadAngle Arduino
Created March 11, 2018 23:16 — forked from JamesNewton/MassMind.org ENC1 3Wire ReadAngle Arduino
Arduino code to read the angle register from the MassMind.org ENC1 via 3 wire read only mode.
/*
Source from
http://forum.arduino.cc/index.php?topic=78881.msg1375885#msg1375885
* Ahmad Byagowi ([email protected])
* Date : Aug 31, 2013
* All code (c)2013 Ahmad Byagowi Consultant. all rights reserved
20170508 Minor edits to improve clarity by James Newton.
*/
//c2 pin tied to ground for 3 wire mode
set -e
PREFIX=~/opt/qt5pi
ROOTFS_MOUNT=/mnt/rasp-pi-rootfs
# On Ubuntu 14.04 do the following first to get the ia32-lib
if [ `lsb_release -ds` -eq "Ubuntu 14.04 LTS" ]
sudo apt-get install lib32z1 lib32ncurses5 lib32bz2-1.0 lib32stdc++6
fi
#! /bin/bash
set -e
trap 'previous_command=$this_command; this_command=$BASH_COMMAND' DEBUG
trap 'echo FAILED COMMAND: $previous_command' EXIT
#-------------------------------------------------------------------------------------------
# This script will download packages for, configure, build and install a GCC cross-compiler.
# Customize the variables (INSTALL_PATH, TARGET, etc.) to your liking before running.
# If you get an error and need to resume the script from some point in the middle,
# just delete/comment the preceding lines before running it again.
#include "mbed.h"
#include "SLCD.h"
#include "MAG3110.h"
#include "fft4g.h"
#include "aqm1248a_lcd.h"
#define NMAX 256
#define NMAXSQRT 32
#define MAX(x,y) ((x) > (y) ? (x) : (y))