Skip to content

Instantly share code, notes, and snippets.

View bevchou's full-sized avatar

Beverly Chou bevchou

View GitHub Profile
@bevchou
bevchou / websocket-controller-esp8266.ino
Created September 11, 2018 05:17
understanding networks - code for tcp client controller
/*
This sketch is based on Tom Igoe's modified version of the EspWiFiTelnetClient sketch.
note: the header file "settings.h" is not included in this repository.
Add a new tab in Arduino, call it "settings.h", and Include the following variables:
char ssid[] = "ssid"; // your network SSID
char password[] = "password"; // your network password
char host[] = "192.168.0.2"; // the IP address of the device running the server
*/
@bevchou
bevchou / stepper_example.ino
Last active May 23, 2018 20:05
Mouse Design - Team Kidnapping Unicorns - Example code for Stepper
// add the stepper motor library
#include <Stepper.h>
// look at the datasheet to see how many steps are in one full rotation
// for instance, if my motor has 200 steps/revolution
// it will rotate 1.8° when you tell it to move 1 step
// because (360°/200) = 1.8°/revolution
const int stepsPerRevolution = 200;
// initialize the stepper library on the motor shield
@bevchou
bevchou / led-websocket.ino
Created April 10, 2018 01:22
ESP8266 project - just the code that gets the data
//Just a section from the websocket code
//Here we are getting the data from the client (browser)
// if new text data is received
case WStype_TEXT:
Serial.printf("[%u] get Text: %s\n", num, payload);
//my data value starts with a '#'
if (payload[0] == '#') {
// decode dropdown data (base 16, 8 bits)
uint32_t combinedData = (uint32_t) strtol((const char *) &payload[1], NULL, 16);
@bevchou
bevchou / websocket.js
Created April 10, 2018 01:14
Javascript (client side) for ESP8266 Websocket/LED controller
//Not the full code
//just a snippet of where I am sending data to the server
function sendToESP(index) {
//update string
getData(index);
//convert data into binary value
combinedData = data[0] << 4 | data[1];
//convert data array to string
dataStr = '#' + combinedData.toString(16);
@bevchou
bevchou / programmers.txt
Created April 10, 2018 00:21
FTDI Friend for programmers.txt to get the code to upload
ftdifriend.name=FTDI Friend bitbang
ftdifriend.communication=serial
ftdifriend.protocol=ftdifriend
@bevchou
bevchou / lightcontroller.ino
Created March 6, 2018 03:42
Arduino MKR1000 code to control DMX lighting in the ITP lounge for Tangible Interaction Workshop
/*
Code for wifi and sACN protocol is based on Tom Igoe's "sACN intro" example
*/
#include <SPI.h>
#include <WiFi101.h>
//#include <ESP8266WiFi.h> // This should work with the ESP8266 as well.
#include <WiFiUdp.h>
#include <sACNSource.h>
#include "arduino_secrets.h"
@bevchou
bevchou / reed-switch-example.ino
Created February 20, 2018 23:03
for tangible interaction workshop sensor report
/******************************************************************************
Reed_Switch_Example.ino
Example sketch for SparkFun's Reed Switch
(https://www.sparkfun.com/products/8642)
Jim Lindblom @ SparkFun Electronics
May 3, 2016
The reed switch is a two-terminal, magnetically-actuated, normally-open switch.
Connect one end of the switch to ground, and the other to Arduino's D2 pin.
@bevchou
bevchou / AIY-voice-test1.py
Created February 17, 2018 22:35
Testing a AIY Voice program to open a browser and respond to specific voice commands
#!/usr/bin/env python3
# Copyright 2017 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
@bevchou
bevchou / midi-pullswitch-instrument.ino
Created February 14, 2018 05:56
Code for pull switch instrument for Tangible Interaction Workshop
#include <SoftwareSerial.h>
//switch variables
int numSwitch = 8;
int switches[] = {A5, A4, A3, A2, A1, A0, 13, 12};
int lastSwitchState[] = {0, 0, 0, 0, 0, 0, 0, 0};
int majChord[] = {0, 1, 2, 2, 3, 4, 5, 5};
//LED variables
int LEDPin[] = {11, 10, 9, 8, 7, 6, 5, 4};
@bevchou
bevchou / TTS.js
Created January 31, 2018 23:13
Node.js TTS project to get the weather
// require "child_process" to run Child Process Applications
var exec = require('child_process').execSync;
function say(something) {
// "say" in this case is a built-in shell command on MAC OS.
command = "say ";
exec(command + something);
}
say("Please enter a U.S. zipcode.");