Skip to content

Instantly share code, notes, and snippets.

View extrasleepy's full-sized avatar

Andrew Kleindolph extrasleepy

View GitHub Profile
@extrasleepy
extrasleepy / gist:187225991a36bfa95cd9
Last active August 29, 2015 14:11
EEPROM example
#include <EEPROM.h>
int led = 12;
int stored; //data stored in EEPROM
int address = 0; //location in EEPROM
void setup() {
Serial.begin(9600); // sets up serial communication at 9600 bitss per second
pinMode(led, OUTPUT);
stored = EEPROM.read(address); // reads the data stored in address 0 and assigns to variable
#include <EEPROM.h>
byte led = 12;
int timesReset = 1; //data stored in EEPROM
byte address1 = 0; //location in EEPROM
byte address2 = 1;
byte retrieved;
void setup() {
@extrasleepy
extrasleepy / gist:9ad7c6439b7b1b93b59b
Last active August 29, 2015 14:11
AVR Direct Port Addressing
//avr direct port addressing
void setup(){
DDRD = B10000000; //digital 7-0 //7 is output here
DDRB = B00010000; //digital 15-8 //12 is output here
}
void loop(){
PORTD = B10000000; //7 high
PORTB = B00000000; //all low
@extrasleepy
extrasleepy / gist:3cd2872c4359601850c8
Last active August 29, 2015 14:11
Getting More Random
int randnumber; //long is another data type, holds a 32 bit numberfloa
void setup() { //set up outputs
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
Serial.begin(9600); //set up serial communication
randomSeed(analogRead(0)); //this will make psudo random numbers seem more random
}
// This sketch demonstrates INPUT_ PULLUP and Interrupts
int ledPin = 7;
volatile boolean flashy = false; //necessary declaration for passing adjusting global variables with interrupts
void setup()
{
pinMode(ledPin, OUTPUT);
pinMode(2, INPUT_PULLUP);
attachInterrupt(0, interruption, FALLING); //attaches interrupt to Digital 2 with internal pull-up resistor
}
@extrasleepy
extrasleepy / gist:c2807755b6276da6bdac
Last active August 29, 2015 14:11
Arduino Serial Write with Pushbutton
// Code for sensing a switch status and writing the value to the serial port.
byte switchPin = 2; // Switch connected to pin 2
void setup() {
pinMode(switchPin, INPUT); // Set pin 2 as an input
Serial.begin(9600); // Start serial communication at 9600 bps
}
void loop() {
@extrasleepy
extrasleepy / gist:3269fc604e0bde755128
Last active August 29, 2015 14:11
Arduino Manipulates Processing
// * Simple Arduino Draw
import processing.serial.*;
Serial myPort; // Create object from Serial class
int val; // Data received from the serial port
void setup()
{
size(800, 500);
#include <Wire.h>
byte kiss = 0;
void setup()
{
Wire.begin();
}
void loop()
#include <Wire.h>
void setup()
{
Wire.begin(1); //declare device address here
Wire.onReceive (beHappy); //acts as interrupt and executed function
Serial.begin(9600);
}
int sensorpin = 2;
int time = 0;
//to hold the time it took for the cap to discharge
void setup() {
Serial.begin(9600);
// For Printing the time it took for the cap to discharge to me
}
void loop() {