Skip to content

Instantly share code, notes, and snippets.

View natendaben's full-sized avatar

Nate Bennett natendaben

View GitHub Profile
@natendaben
natendaben / Lab_2.ino
Created September 19, 2018 14:45
A brief Neopixel strip demonstration using two simple buttons
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif
//pin that the strip is connected to
#define PIN 4
//set some variables
const int firstbutton = 2;
//analog inout and output
int pot = 0; //stores pot value
int potPin = A0;
int redLED = 9;
int brightness1 = 0; //value to hold LED brightness
int brightness2 = 0;
int photoPin = A1;
int lightValue = 0;
int yellowLED = 10;
@natendaben
natendaben / lab3pt2.ino
Created October 4, 2018 15:09
Lab 3 Pt. 2
int light = 0;
float frequency = 0;
void setup() {
// init serial comm
Serial.begin(9600);
pinMode(8, OUTPUT);
pinMode(A0, INPUT);
@natendaben
natendaben / lab3pt2extended.ino
Created October 4, 2018 15:19
Harry Potter Jingle
int light = 0;
float frequency = 0;
void setup() {
// init serial comm
Serial.begin(9600);
pinMode(8, OUTPUT);
pinMode(A0, INPUT);
@natendaben
natendaben / lab3final.ino
Created October 4, 2018 16:42
Lab 3 Part 3
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif
//pin that the strip is connected to
#define PIN 13
//first argument is # pixels - change to how many you have
Adafruit_NeoPixel strip = Adafruit_NeoPixel(5, PIN, NEO_GRB + NEO_KHZ800);
@natendaben
natendaben / allsensortest.ino
Created October 27, 2018 04:54
Blinko Project Code
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif
//pin that the Neopixel strip is connected to
#define PIN 2
int sad = LOW; //variable for when "lose" channel triggers
int jackpot = LOW; //variable for when "win" channel triggers
@natendaben
natendaben / lab4.ino
Created November 1, 2018 23:20
Lab 4
int pot = 0;
int pot2 = 0;
int incoming; //variable for storing incoming data
void setup() {
Serial.begin(9600);
pinMode(2, OUTPUT);
}
void loop() {
@natendaben
natendaben / servo.ino
Created November 16, 2018 00:01
Servo Code
#include <Servo.h>
//make instance of servo object
Servo mike;
void setup() {
// put your setup code here, to run once:
//attach servo motor
@natendaben
natendaben / DCmotor.ino
Created November 16, 2018 00:18
DC Motor Code
const int switchPin = 2; // switch input
const int motor1Pin = 3; // H-bridge leg 1 (pin 2, 1A)
const int motor2Pin = 5; // H-bridge leg 2 (pin 7, 2A)
const int enablePin = 9; // H-bridge enable pin
void setup() {
// set the switch as an input:
pinMode(switchPin, INPUT);
// set all the other pins you're using as outputs:
@natendaben
natendaben / stepper.ino
Created November 16, 2018 00:42
Stepper Motor
//Declare pin functions on Redboard
#define stp 2
#define dir 3
#define MS1 4
#define MS2 5
#define EN 6
//Declare variables for functions
char user_input;
int x;