Skip to content

Instantly share code, notes, and snippets.

View VincentK16's full-sized avatar
:octocat:
Connect with me

Vincent Kok VincentK16

:octocat:
Connect with me
View GitHub Profile
@VincentK16
VincentK16 / gist:5450215
Created April 24, 2013 07:13
My First Stackable Circuit
int led1 = 5;
int led2 = 6;
int led3 = 7;
int led4 = 8;
int led5= 9;
int led6= 10;
int led7 = 11;
int BUTTON = 12;
void setup() {
@VincentK16
VincentK16 / Wireless Controlled Relay
Created June 27, 2013 14:11
Wireless Controlled Relay
int pin = 8;
void setup(){
Serial.begin(9600);
pinMode(pin,OUTPUT);
digitalWrite(pin,LOW);
}
void loop()
{
@VincentK16
VincentK16 / DS1307 RTC
Last active December 31, 2017 11:21
DS 1307 Simple Sketch
#include <Wire.h>
#include "RTClib.h"
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
RTC_DS1307 RTC;
void setup () {
Serial.begin(9600);
Wire.begin();
RTC.begin();
@VincentK16
VincentK16 / HC-SR04 Ultrasonic Sensor
Created July 1, 2013 11:34
This is a simple coding that display the distance of the obstacle to the sensor. When the sensor is approaching the obstacle, the buzzer will sound at a higher rate.
#include <NewPing.h>
#define TRIGGER_PIN 12 // Arduino pin tied to trigger pin on the ultrasonic sensor.
#define ECHO_PIN 11 // Arduino pin tied to echo pin on the ultrasonic sensor.
#define MAX_DISTANCE 200 // Maximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm.
NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance.
void setup() {
Serial.begin(115200); // Open serial monitor at 115200 baud to see ping results.
/*
Copyright (C) 2011 J. Coliz <maniacbug@ymail.com>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
version 2 as published by the Free Software Foundation.
*/
/**
* Example RF Radio Ping Pair
@VincentK16
VincentK16 / Active-LOW button
Created July 11, 2013 08:50
This is the code for active-LOW button which we turn on an LED when the switch is pressed
const int buttonPin = 8; // the number of the pushbutton pin
const int ledPin = 13; // the number of the LED pin
// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
void setup() {
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the pushbutton pin as an input:
@VincentK16
VincentK16 / Active-HIGH button
Created July 11, 2013 08:52
This is the code for Active-HIGH button which we turn on an LED when the switch is pressed
const int buttonPin = 3; // the number of the pushbutton pin
const int ledPin = 2; // the number of the LED pin
// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
void setup() {
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the pushbutton pin as an input:
@VincentK16
VincentK16 / Temperature-Controlled DC Fan
Last active December 19, 2015 21:19
This is a very simple coding to make an temperature-controlled automatic fan. It will display the temperature at the 16 X 2 LCD screen. When the temperature is more than 35 degree celcius, it will trigger the relay and get the DC fan to ON.
#include <LiquidCrystal.h>
int reading = 0;
int sensorPin = A0;
int relay =7;
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
@VincentK16
VincentK16 / Mini Piano V1.0(Arduino)
Last active December 22, 2015 00:38
Mini Piano V1.0
int speaker = 13;
int button_1 = 0;
int button_2 = 1;
int button_3=2;
int button_4 = 3;
int button_5 = 4;
int button_6=5;
int button_7=6;
int button_8=7;
int button_9=8;
@VincentK16
VincentK16 / Mini Piano V1.0
Created September 15, 2013 16:17
Mini Piano V1.0 - Using arduino to generate melody !
int led = A0;
int speaker = 13;
int button_1 = 0;
int button_2 = 1;
int button_3=2;
int button_4 = 3;
int button_5 = 4;
int button_6=5;
int button_7=6;
int button_8=7;