This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// constants for the pins | |
const int LEDPin = 2; | |
const int switchPin = 3; | |
// variables for the previous switch state and LED | |
int ledState = LOW; | |
int lastSwitchVal = LOW; | |
void setup() { | |
// configure your pins | |
pinMode(LEDPin, OUTPUT); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const int LEDPin = 2; | |
const int switchPin = 3; | |
int switchVal; | |
void setup() { | |
// configure your pins | |
pinMode(LEDPin, OUTPUT); | |
pinMode(switchPin, INPUT); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// this sketch is for use with a L293D stepper motor and an Arduino | |
// pin 3 is connected to the enable pin for PWM control of speed | |
// pins 4 and 5 are connected to motor control inputs | |
// a pot connected to pin A0 is used as an interface for speed | |
// a switch connected to pin 6 controls the direction of the motor | |
int motorSpeed = 0; // variable for the motor speed | |
int sensorPin = A0; // analog input pin woiht the pot | |
int switchPin = 6; // variable for the button | |
int enablePin = 3; // pin to control motor speed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Adafruit_NeoPixel.h> | |
#define LED_PIN 3 | |
#define LED_COUNT 5 | |
Adafruit_NeoPixel leds(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800); | |
byte bright = 0; | |
void setup() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const int potPin = A0; // pin the switch is connected to | |
int potVal; // variable to hold the value from the switch | |
void setup() { | |
Serial.begin(9600); | |
} | |
void loop() { | |
// read the value of the pot and store it |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// include the neopixel library | |
#include <Adafruit_NeoPixel.h> | |
int ledPin = 3; // the pin the LED data line is connected to | |
int numLED = 5; // number of LEDs you are controlling | |
// call the constructor for the neopixels | |
Adafruit_NeoPixel leds(numLED, ledPin, NEO_GRB + NEO_KHZ800); | |
int input[] = {0, 0, 0}; // an array to hold color data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Creates a randomly sparkling effect on an arbitrary number of | |
LEDs using the WS2812 driver. | |
*/ | |
#include <Adafruit_NeoPixel.h> // include the neopixel library | |
// most people use FastLED for the blinkytape, but the Adafruit | |
// library is more my speed | |
#define PIN 3 // we're using the blinkytape, data is pin 13 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// include the neopixel library | |
#include <Adafruit_NeoPixel.h> | |
int ledPin = 3; // the pin the LED data line is connected to | |
int numLED = 5; // number of LEDs you are controlling | |
// call the constructor | |
Adafruit_NeoPixel leds(numLED, ledPin, NEO_GRB + NEO_KHZ800); | |
int sensorPin = A0; // pin the sensor is attached to |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// include the neopixel library | |
#include <Adafruit_NeoPixel.h> | |
int ledPin = 3; // the pin the LED data line is connected to | |
int numLED = 5; // number of LEDs you are controlling | |
// call the constructor | |
Adafruit_NeoPixel leds(numLED, ledPin, NEO_GRB + NEO_KHZ800); | |
// variables to hold colors |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int firstSensor = 0; // first analog sensor | |
int secondSensor = 0; // second analog sensor | |
int thirdSensor = 0; // digital sensor | |
int inByte = 0; // incoming serial byte | |
void setup() { | |
// start serial port at 9600 bps and wait for port to open: | |
Serial.begin(9600); | |
while(!Serial){ | |
;; |