Skip to content

Instantly share code, notes, and snippets.

View mjvo's full-sized avatar

Mark Olson mjvo

View GitHub Profile
@mjvo
mjvo / Fork own Repo of Slide Server
Last active August 20, 2016 21:04
Git instructions for forking own repo using reveal-jekyll-slideserver as example
git clone https://github.com/mjvo/reveal-jekyll-slideserver NEW_REPO
cd NEW_REPO
[create NEW_REPO on github.com]
git remote set-url origin https://github.com/mjvo/NEW_REPO.git
git push origin gh-pages
git remote add upstream https://github.com/mjvo/reveal-jekyll-slideserver.git
git remote -v
@mjvo
mjvo / OutputFromP5js.ino
Last active February 17, 2017 01:01
Serial Output from P5.js - Arduino and p5js code
// Arduino code for Redboard
const int ledPin = 5; // the pin that the LED is attached to
int incomingByte; // a variable to read incoming serial data into
void setup() {
// initialize serial communication:
Serial.begin(9600); // note baudrate set at 9600. Other speeds available/must be matched in P5.js options
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
}
@mjvo
mjvo / Input2p5js.ino
Last active March 7, 2019 12:13
Serial Input to P5.js - Arduino and p5js code
void setup() {
Serial.begin(9600); // initialize serial communications @ 9600
}
void loop() {
int potentiometer = analogRead(A0); // read the input pin
int mappedPot = map(potentiometer, 0, 1023, 0, 255); // remap the pot value to fit in 1 byte
//Serial.write(mappedPot); // write mappedPot value to the serial port (1 byte)
Serial.println(potentiometer); // *or* use println to print out raw potentiometer value with newline as data separator
delay(1); // slight delay to stabilize the ADC
@mjvo
mjvo / sketch.js
Last active June 14, 2021 18:53
p5js Typewriter - uses the text() function but could easily use createElement() and html().
var data = "This is a sentence!";
var data2 = "This is a second sentence";
function setup() {
createCanvas(400,400);
typeWriter(data, 0, 20, 30, 100);
typeWriter(data2, 0, 20, 50, 500);
}
function draw() {
@mjvo
mjvo / MQTT_FeatherMO.ino
Last active August 10, 2020 12:51
Quickstart code for Arduino MQTT communication
/*
####################################################################################
MQTT PubSub implementation for Feather M0
For information on configuration:
http://mjvo.github.io/tutorials/circuits/mqtt/
External libraries required (available through Arduino Library Manager):
- WiFi101: https://www.arduino.cc/en/Reference/WiFi101
- PubSub Client by Nick O'Leary: https://pubsubclient.knolleary.net/
- arduino-timer by Michael Contreras: https://github.com/contrem/arduino-timer
// Arduino library dependencies
#include <SPI.h>
#include <WiFi101.h>
#include <timer.h>
#include <ArduinoJson.h>
// ************
// Enter your wifi access credentials in the tab: arduino_secrets.h
// ************
#include "arduino_secrets.h"
// Arduino library dependencies
#include <SPI.h>
#include <WiFi101.h>
#include <timer.h>
#include <ArduinoJson.h>
// ************
// Enter your wifi access credentials and base64 encoded Twitter API
// key and secret in the tab: arduino_secrets.h
// ************
@mjvo
mjvo / sample.json
Last active July 26, 2020 18:12
3D WebXR Viewer JSON (Sample)
{
"title": "Some 3D Collection",
"desc": "This is a description of this particular collection of 3D objects.",
"viewer-settings": "some array of additional global model-viewer settings could go here (shadow intensity, autoplay, environment image, etc)",
"objects": [{
"id": 2213,
"poster": "path/to/2213.png",
"src": "path/to/2213.glb",
"ios": "path/to.2213.usdz",
"hotspots": [{
"""
Read the Serial port to receive color data for the neopixel.
This uses the optional second serial port available in Circuitpython 7.x
Activate it in the boot.py file with the following code
import usb_cdc
usb_cdc.enable(console=True, data=True)
@mjvo
mjvo / index.html
Last active March 15, 2024 12:15 — forked from kotobuki/script.js
Web Bluetooth in p5js with Adafruit Circuit Playground Bluefruit (UART)
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.9.1/p5.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.9.1/addons/p5.sound.min.js"></script>