Skip to content

Instantly share code, notes, and snippets.

View pearlchen's full-sized avatar

Pearl Chen pearlchen

  • Make This Studio
  • Toronto, ON
View GitHub Profile
function serve() {
local host=`hostname`
local port="${1:-8888}"
(sleep 1 && open "http://${host}:${port}/")&
python -m SimpleHTTPServer "$port"
}
@pearlchen
pearlchen / blinkTest.cpp
Last active August 29, 2015 14:25
2 different versions of the bare minimum code required to blink an LED on pin 13 (aka J17-14) using an Intel Edison and C++.
#include "mraa.hpp"
int main()
{
// set GPIO digital pin "13" to be an output
mraa_gpio_context d_pin = mraa_gpio_init_raw(128);
mraa_gpio_dir(d_pin, MRAA_GPIO_OUT_HIGH);
// loop forever toggling the on board LED every second
for (;;) {
// example code of touch numbers (replaces getTouchNumber)
#include <Wire.h>
#include "Seeed_QTouch.h"
#include <SeeedOLED.h>
void setup()
{
Serial.begin(9600);
@pearlchen
pearlchen / lcd_text_helper.js
Last active November 8, 2015 04:37
Scroll text across your Grove LCD screen using JavaScript on the Intel Edison or Intel Galileo. Video: https://twitter.com/PearlChen/status/588890387260903424. And check it out within a larger project: https://github.com/pearlchen/iot-smart-desk-clock
/* global setInterval: false, setTimeout: false, clearInterval: false, clearTimeout:false, module: false, console: false */
/**
* Module exports.
*/
module.exports = LcdTextHelper;
/**
* LcdTextHelper constructor.
@pearlchen
pearlchen / intel-edison-grove-lcd-Jhd1313m1-example
Created April 14, 2015 02:23
Make a little * dance across your Grove LCD screen using JavaScript on the Intel Edison or Intel Galileo. Video: https://twitter.com/PearlChen/status/587808490405625856
var mraa = require ('mraa');
/*
If you get any mraa missing errors, run this on your board:
$ echo "src mraa-upm http://iotdk.intel.com/repos/1.1/intelgalactic" > /etc/opkg/mraa-upm.conf
$ opkg update
$ opkg install libmraa0
*/
var LCD = require ('jsupm_i2clcd');
/*
<script>
/** Convert a decimal number to a hex number. */
function convertDecToHex(dec) {
var BASE = 16,
result = '';
return getHex( dec );
@pearlchen
pearlchen / Lighthouse.ino
Created October 19, 2013 19:43
Use analogWrite() to fade an LED up and down.
int ledPin = 6; // Note that pin 13 on the Uno doesn't support PWM!
int brightness = 0;
int stepValue = 1;
void setup() {
pinMode(ledPin, OUTPUT); // sets the pin as output
}
void loop() {
@pearlchen
pearlchen / multiple_angular_services.js
Created December 19, 2012 23:15
Need to create an AngularJS service that can implement multiple API URL paths, while also post "clean" data? This is my version for a solution. See the bottom of the gist for some more detail.
// YOUR ANGULAR SERVICE
clientApp.factory('Mongo', function($resource) {
// $resource(url[, paramDefaults][, actions]);
return $resource('http://localhost\\:8000/api/:action/:huddleId',
{
action: '@action',
huddleId: '@huddleId'
},
{
@pearlchen
pearlchen / moboto
Created November 25, 2012 18:43
Mr.Moboto draws a 'stauche
#include <Servo.h>
//Servo
Servo armServo;
Servo baseServo;
const int ARM_SERVO = 9;
const int BASE_SERVO = 10;
// motor constants & limitations
const int minArmServoPos = 30; //don't go lower, will hit the base
@pearlchen
pearlchen / gist:4142125
Created November 25, 2012 02:14
Drawing Robot
#include <Servo.h>
//Servo
Servo armServo;
const int ARM_SERVO = 9;
Servo baseServo;
const int BASE_SERVO = 10;
// drawing variables