Skip to content

Instantly share code, notes, and snippets.

View extrasleepy's full-sized avatar

Andrew Kleindolph extrasleepy

View GitHub Profile
// LED Fadeing Example (PWM) http://arduino.cc/en/Reference/AnalogWrite
void setup() {
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT); //NO PWM
pinMode(8, OUTPUT); //NO PWM
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
@extrasleepy
extrasleepy / gist:dc4a69042efc20bc9108
Created April 3, 2015 23:41
Spark variable post to web
int sensorValue;
// the setup routine runs once when you press reset:
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
Spark.variable("light", &sensorValue, INT);
}
// the loop routine runs over and over again forever:
void loop() {
//Modified from SoftPWM library example at: https://code.google.com/p/rogue-code/wiki/SoftPWMLibraryDocumentation#Usage_Example
//SoftPWM library must be installed
//NF for Design & Technology at LWHS Dec 2014 (modification: added all D&T "sleepyBoard" lamp board pins)
//Explanation: On the D&T lamp boards, only pins 5, 6, 9, 10, and 11 (not 7, 8, or 12) are "PWM enabled" and work with
//the analogWrite function. Built into the hardware on those pins is a way to toggle very quickly between on
//and off, leading to a dimmer or brighter LED, depending on the ratio of "on" times to "off" times.
//However, it's possible to replicate this effect in software, which is what the SoftPWM Arduino library does.
//Challenge 1: can you made the LEDs fade at different rates?
<?php
// Check for empty fields
if(empty($_POST['name']) ||
empty($_POST['email']) ||
empty($_POST['phone']) ||
empty($_POST['message']) ||
!filter_var($_POST['email'],FILTER_VALIDATE_EMAIL))
{
echo "No arguments Provided!";
return false;
@extrasleepy
extrasleepy / contact_me.js
Last active December 5, 2019 19:35
contact_me.js
$(function() {
$("input,textarea").jqBootstrapValidation({
preventSubmit: true,
submitError: function($form, event, errors) {
// additional error messages or events
},
submitSuccess: function($form, event) {
// Prevent spam click and default submit behaviour
$("#btnSubmit").attr("disabled", true);
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="Andrew Kleindolph">
<title>Number Fog Patterns</title>
@extrasleepy
extrasleepy / clockcode.ino
Created September 17, 2015 15:04
Code for Binary Clock - run setTime.ino to set clock, then run clockcode.ino to use time to control LEDs
//orignal code made by M Atkinson, please check his website http://www.multiwingspan.co.uk
//few minor modifications made by cronos_80@hotmail.com
#include <Wire.h>
#include "RTClib.h"
RTC_DS1307 RTC;
int datapin = 2;
int clockpin = 3;
int latchpin = 4;
// called once on startup
void setup() {
// For simplicity, we'll format our weather data as text, and pipe it to serial.
// but you could just as easily display it in a webpage or pass the data to another system.
// Learn more about the serial commands at https://docs.particle.io/reference/firmware/photon/#serial
// for the Photon, or https://docs.particle.io/reference/firmware/core/#serial for the Core
// You can also watch what's sent over serial with the particle cli with
// particle serial monitor
Serial.begin(115200);
//pin hookups:
//LCD TX = Photon TX
//LCD 5v = Photon Vin (with USB hooked up) will not operate on 3.3v
//LCD GND = Photon GND
#define lcd Serial1
void setup() {
lcd.begin(9600);
// -----------------------------------
// Controlling LEDs over the Internet
// -----------------------------------
// First, let's create our "shorthand" for the pins
// Same as in the Blink an LED example:
// led1 is D0, led2 is D7
int led1 = D0;
int led2 = D7;