Skip to content

Instantly share code, notes, and snippets.

View soundanalogous's full-sized avatar

Jeff Hoefs soundanalogous

  • San Francisco, CA
View GitHub Profile

Building an ultrasonic sensor backpack

Note: This is a bit of a scratch to see what's involved in getting the ping sensor to work as an I2C backpack.

Dependencies.

I did this on a Trinket as that's what I had to hand to make programming a bit faster. If you use a trinket you will need the custom arduino. Check out the Adafruit Trinket info https://learn.adafruit.com/introducing-trinket/introduction

You also need a custom form of the TinyWireS library that manages sending multiple registers on one read request (the

@soundanalogous
soundanalogous / nano_every.h
Last active December 2, 2020 13:34
Arduino Nano Every Firmata Boards.h definition
// Unverified
#elif defined(AVR_NANO_EVERY)
#define TOTAL_ANALOG_PINS 8
#define TOTAL_PINS 24 // 14 digital + 8 analog + 2 i2c
#define IS_PIN_DIGITAL(p) ((p) >= 2 && (p) <= 21) // TBD if pins 0 and 1 are usable
#define IS_PIN_ANALOG(p) ((p) >= 14 && (p) < 14 + TOTAL_ANALOG_PINS)
#define IS_PIN_PWM(p) digitalPinHasPWM(p)
#define IS_PIN_SERVO(p) (IS_PIN_DIGITAL(p) && (p) < MAX_SERVOS) // deprecated since v2.4
#define IS_PIN_I2C(p) ((p) == PIN_WIRE_SDA || (p) == PIN_WIRE_SCL) // SDA = 22, SCL = 23
#define IS_PIN_SPI(p) ((p) == SS || (p) == MOSI || (p) == MISO || (p) == SCK)
/*
Firmata is a generic protocol for communicating with microcontrollers
from software on a host computer. It is intended to work with
any host computer software package.
To download a host software package, please click on the following link
to open the list of Firmata client libraries in your default browser.
https://github.com/firmata/arduino#firmata-client-libraries
@soundanalogous
soundanalogous / FirmataSerialTest.ino
Last active April 2, 2020 18:53
Firmata Serial protocol device emulator
/*
* Emulate a simple serial device in order to test the Firmata Serial protocol.
* Connect the rxPin to the TX pin of the configured port of the board running StandardFirmata
* Connect the txPin to the RX pin of the configured port of the board running StandardFirmata
*
* Use Serial to read and write to the board running StandardFirmata
* Use SoftwareSerial to write data to a console to test SERIAL_WRITE
*/
#include <SoftwareSerial.h>
@soundanalogous
soundanalogous / blink-firmata-esp.js
Last active August 25, 2019 18:58
ESP8266 client demo for Firmata.js
@soundanalogous
soundanalogous / ble-j5-test.js
Last active August 23, 2018 19:31
johnny-five example for StandardFirmataBLE and Arduino 101
/*
* To run, install the following modules:
* npm install ble-serial
* npm install johnny-five
*
* wiring:
* button to pin D2
* button to pin A2
* LED to pin D10
* potentiometer to pin A0
/*
Firmata is a generic protocol for communicating with microcontrollers
from software on a host computer. It is intended to work with
any host computer software package.
To download a host software package, please click on the following link
to open the list of Firmata client libraries in your default browser.
https://github.com/firmata/arduino#firmata-client-libraries
@soundanalogous
soundanalogous / ble-nano-test.js
Last active September 4, 2017 23:33
StandardFirmataBLE test for RedBearLab BLE Nano
/*
* NOTE: This will not run without modification until this issue is resolved:
* https://github.com/RedBearLab/nRF51822-Arduino/pull/97.
*
* Until then, you will need to patch the RedBearLab nRF51822-Arduino core
* library by following these instructions:
* 1. Install v1.0.7 of the RedBear nRF51822 Boards package using the Arduino
* Boards Manager (Tools > Boards > Boards Manager...). If you have a newer
* version already installed, first downgrade to v1.0.7.
* 2. Clone https://github.com/soundanalogous/nRF51822-Arduino and checkout the
@soundanalogous
soundanalogous / ble-firmata-test.js
Last active December 30, 2016 17:24
node.js example for StandardFirmataBLE with Arduino 101
/*
* Make sure the Intel Curie Boards by Intel board package version 1.0.6 or higher is installed
* via the Arduino Boards Manager
*
* Compile and upload StandardFirmataBLE from the firmata/arduino master branch.
*
* To run, install the following modules:
* npm install ble-serial
* npm install firmata
*
/*
OneWireFirmata.cpp - Firmata library
Copyright (C) 2012-2013 Norbert Truchsess. All rights reserved.
Copyright (C) 2016 Jeff Hoefs. All rights reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.