Skip to content

Instantly share code, notes, and snippets.

@jso-07
jso-07 / Part C: Serial 5.5
Created January 26, 2016 21:08
Tutorial 2
const int SENSOR = A0; // select the input pin for the
// sensor resistor
int val = 0; // variable to store the value coming
// from the sensor
void setup() {
Serial.begin(9600); // open the serial port to send
// data back to the computer at
// 9600 bits per second
}
void loop() {
@jso-07
jso-07 / Part B. 5.4
Created January 26, 2016 20:35
Tutorial 2
const int LED = 9; // the pin for the LED
int val = 0; // variable used to store the value coming from the sensor
void setup() {
pinMode(LED, OUTPUT); // LED is as an OUTPUT
}
void loop() {
val = analogRead(0); // read the value from
// the sensor
@jso-07
jso-07 / Part A: Dimmer Switch
Last active January 26, 2016 20:22
Tutorial 2 Example 5.2
const int LED = 9; // the pint for the LED
const int BUTTON = 7; // input pin of the pushbutton
int val = 0; //stores the state of the input pin
int old_val = 0; //stores the previous value of "val"
int state = 0; //0 = LED off while 1 = LED on
int brightness = 128; //stores the brightness value
unsigned long startTime = 0; //wjem dod we begin pressing?
@jso-07
jso-07 / Hacking
Last active January 21, 2016 15:33
Tutorial 1 Part C
const int REDLED = 13; // the pin for the LED
const int YELLOWLED = 12;
const int GREENLED = 11;
const int BUTTON = 7; // the input pin where the pushbutton is connected
int val = 0; // val will be used to store the state of the input pin
int state = 0; // 0 = LED off and 1 = LED on
void setup() {
@jso-07
jso-07 / Push Button 4.5
Created January 20, 2016 19:05
Tutorial 1 Part B Example 4.5
const int LED = 13; // the pin for the LED
const int BUTTON = 7; // the input pin where the pushbutton is connected
int val = 0; // val will be used to store the state of the input pin
int old_val = 0; // this variable stores the previous value of "val"
int state = 0; // 0 = LED off and 1 = LED on
void setup() {
pinMode(LED, OUTPUT); // tell Arduino LED is an output
@jso-07
jso-07 / Blinking LED
Created January 19, 2016 18:52
Part A: Blink
// Blinking LED
const int LED = 13; // LED connected to digital pin 13
void setup() {
pinMode(LED, OUTPUT); // Sets digital pin as output
}
void loop() {
@jso-07
jso-07 / Wearable Lights Project Code: Jasmine So
Last active November 5, 2015 05:37
Altered Lilytwinkle Code
dir *= -1;
on_time = interval - dead_time;
}
else if (on_time <= 0) {
on_time = 0;
dir *= -1;
LED_tracker1 = LED_tracker2;
while (LED_tracker1 == LED_tracker2) LED_tracker1 = random(1,10);
offset2 = random(0,4000);
}
@jso-07
jso-07 / Vertebrae by Vertebrae
Created February 9, 2015 13:17
red LED to green when stretch sensors are engaged
// initialize serial communication at 9600 bps
int lightSensorValue = 0;
int lightSensorPin = A2;
int greenLEDPin = 9; // LED connected to digital pin 9
int redLEDPin = 10; // LED connected to digital pin 10
int redValue = 0; // value to write to the red LED
int greenValue = 0; // value to write to the green LED
void setup() {
Serial.begin(9600);