Skip to content

Instantly share code, notes, and snippets.

@arielchuri
arielchuri / LEDtestSIMPLE.ino
Created February 10, 2014 21:42
Code for testing your 6 LEDs
int timer = 60; // The higher the number, the slower the timing.
int ledPins[] = {
11, 10, 9, 6, 5, 3 }; // an array of pin numbers to which LEDs are attached
int pinCount = 6; // the number of pins (i.e. the length of the array)
void setup() {
// the array elements are numbered from 0 to (pinCount - 1).
// use a for loop to initialize each pin as an output:
for (int thisPin = 0; thisPin < pinCount; thisPin++) {
@arielchuri
arielchuri / LEDtest.ino
Last active August 29, 2015 13:56
Code for testing your 6 LEDs with some additional debugging.
//
// +--------+
// | TOUCH |
// | SENSOR |
// | |
// +------ |
// ARDUINO |
// +-----------+ |
// | GND|-----------------+ |
// | | | |
@arielchuri
arielchuri / capSense.ino
Created November 12, 2013 19:46
Night light with touch sensor
// Block Diagram
// +---------------------+
// | State 0: |
// | Check light sensor |
// | If it is dark: <---+
// | - Turn on light | |
// | - Change State to 1 | |
// | - Remember the time | |
// +---------+-----------+ |
// | |
@arielchuri
arielchuri / nightlightstarter.ino
Last active December 27, 2015 12:19
States 0 and 1 of a simple nightlight.
// Block Diagram
// +---------------------+
// | State 0: |
// | Check light sensor |
// | If it is dark: <---+
// | - Turn on light | |
// | - Change State to 1 | |
// | - Remember the time | |
// +---------+-----------+ |
// | |
@arielchuri
arielchuri / lightsensor.ino
Created September 6, 2013 20:09
Light Sensor code for the Emerging Objects class.
//Light Sensor Code
int led = 13;
int led2 = 11;
byte fade;
long timer;
long previousTimer;
int ledState = LOW;
//Blinking and Fading
int led = 13;
int led2 = 11;
// This time the fade variable is a byte instead of an int.
byte fade;
// A big variable to keep track of the timer.
long timer;
@arielchuri
arielchuri / Fade.ino
Created September 6, 2013 20:04
Emerging Objects Class Code
int led = 13;
int led2 = 11;
int blinks;
int fade;
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(led, OUTPUT);
pinMode(led2, OUTPUT);
Serial.begin(9600);
int led = 13;
int led2 = 11;
int blinks;
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(led, OUTPUT);
pinMode(led2, OUTPUT);
Serial.begin(9600);
//Blink code:
// int is type of variable. variables are where we store information.
// here we store the name of our LED pin.
int led = 13;
// another variable as an example.
int blinks;
// the setup routine runs once in the beginning.
// Setup the touch sensor.
#include <CapacitiveSensor.h>
CapacitiveSensor cs_4_2 = CapacitiveSensor(4,2);
// Setup the light sensor
int sensorPin = A0;
int sensorValue = 0;
boolean dark = false;
// Set up the LEDs