Skip to content

Instantly share code, notes, and snippets.

@sj82516
sj82516 / gist:90cc040fdaa44a4a1117
Created July 21, 2014 08:23
Arduino_Lab7_extends
// 七段顯示器製作倒數功能 (v1)
int potPin=3;
byte seven_seg_digits[10][7] = {
{ 1,1,1,1,1,1,0 }, // = 0
{ 0,1,1,0,0,0,0 }, // = 1
{ 1,1,0,1,1,0,1 }, // = 2
{ 1,1,1,1,0,0,1 }, // = 3
{ 0,1,1,0,0,1,1 }, // = 4
{ 1,0,1,1,0,1,1 }, // = 5
{ 1,0,1,1,1,1,1 }, // = 6
@sj82516
sj82516 / gist:7d95b81fe2655f9b0230
Created July 30, 2014 09:31
Arduin0_keypad input password and shows on LCD
// 引用 Keypad library
#include <Keypad.h>
#include <Password.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,16,2);
char *pwd={"123"};
Password password = Password(pwd);
@sj82516
sj82516 / gist:efd30e89d3056c7ecd40
Created August 20, 2014 07:02
Arduino_personal work_alarm_v1
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <virtuabotixRTC.h>
//use interrupt 0 -> pin 2 (button0)
#define lock 0
//button1
#define add_sec 4
//button2
#define add_min 3
@sj82516
sj82516 / gist:9c8d0530e1407b62e1f6
Created September 14, 2014 00:04
Arduino_robotFaceDIY
#include <Servo.h>
#include <IRremote.h>
//IR
int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;
const unsigned long IRmove1 = 0XFF30CF;
const unsigned long IRmove2 = 0XFF18E7;
const unsigned long IRmove3 = 0XFF7A85;
@sj82516
sj82516 / gist:63753da1808c839253eb
Last active August 29, 2015 14:07
Arduino_digitalPiano
//set up pin
const int buttonPin = 2;
const int hornPin = 3;
const int ohm=5;
//data
int music[5]={0,0,0,0,0};
int point=0;
int sensor=0;
boolean buttonState=LOW;
long lastDebounceTime = 0;
// Lab01
// LM35 + 4*7 segment Display
// 七段顯示器 reference: Cooper Maa
// define the LED digit patterns, from 0 - 9
// 1 = LED on, 0 = LED off, in this order:
// Arduino pin: 2,3,4,5,6,7,8 (Mapping a,b,c,d,e,f,g of Seven-Segment LED)
byte seven_seg_digits[10][7] = { { 1,1,1,1,1,1,0 }, // = 0
{ 0,1,1,0,0,0,0 }, // = 1
{ 1,1,0,1,1,0,1 }, // = 2
@sj82516
sj82516 / gist:7ec10ff907b9e1a3db82
Last active August 29, 2015 14:17
NCTU_Embedded system_Arduino_Lab02
//NCTU_Embedded system_Arduino_Lab02
//Read and compare sensor
//then display on 5*7 LED matrix
//show the "HelloWorld" and shift left or right by the comparison
//display like this project:http://musicdiver.com/wordpress/2013/01/arduino-scrolling-text-on-5x7-led/
int scan=0;
int matrix[7][50];
//transform letter to 5*7 LED matrixs
Doctype
html
head
meta(charset='utf-8')
title #{title}
script(src='/javascripts/Chart.min.js')
body
canvas#myChart
script(type="text/javascript").
var data = {
var express = require('express');
var router = express.Router();
/* GET home page. */
router.get('/', function(req, res, next) {
var chartData = [];
for (var i = 0; i < 7; i++)
chartData.push(Math.random() * 50);
res.render('index', { title: 'Express', chartData: JSON.stringify(chartData) });
@sj82516
sj82516 / form.jade
Last active January 18, 2016 00:09
NodeJs-form/Ajax/Handle request
form#formArticle(role="form")
div.form-group
label(for="createArticleTitle") Article Title
textarea.form-control(row="1" name="title")
label(for="createArticleBody") Article Body
textarea.form-control(row="6" name="description")
button(type="submit")
//使用jquery的serialize()-直接將form各個欄位值轉為POST/GET傳遞的格式
//Use Jquery serialize() function - turn the values of cloumns in form into POST/GET format
//*項目必須要有 name