This file contains hidden or 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 example employs Timer1 to blink one of three LEDs. The timer is called | |
within a For Loop which repeatedly calls a function that alternately flashes the | |
other two LEDs. The timer is "turned on" runs for a specified portion of the For Loop | |
and is then "turned off". | |
*/ | |
#include <TimerOne.h> | |
const int blinkLed = 3; // the pin with a LED that should blink | |
const int buttonLed1 = 4; // led controlled by button |
This file contains hidden or 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
/* Example code for a four transistor, four diode | |
H-Bridge | |
*/ | |
// Assign four H-Bridge inputs to PWM pins | |
int r1 = 6; | |
int r2 = 9; | |
int r3 = 10; | |
int r4 = 11; |
This file contains hidden or 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
/* | |
Debounce | |
Each time the input pin goes from LOW to HIGH (e.g. because of a push-button | |
press), the output pin is toggled from LOW to HIGH or HIGH to LOW. There's | |
a minimum delay between toggles to debounce the circuit (i.e. to ignore | |
noise). | |
The circuit: | |
* LED attached from pin 13 to ground |
This file contains hidden or 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
// Define constants | |
const int buttonPin = 2; | |
// Define variables | |
boolean buttonState = HIGH; | |
// Setup |
This file contains hidden or 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
// Define constants | |
const int buttonPin = 2; | |
// Define variables | |
boolean buttonState = HIGH; | |
// Setup |
This file contains hidden or 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
/* Shows the use of a user-defined function call from loop(). | |
The sketch also uses a flag variable to keep track of the | |
current position state of the potentiometer. | |
The potentiometer is used to provide and analog signal to pin | |
A0. When the value of the analog read variable potVal goes | |
from a value that is below 400 to a value that is above | |
the threshold value of 600 the function lights() is called to | |
flash the green and red LEDs. The function is not called again | |
until the pot is again cycle below 400 and then above 600. This |
This file contains hidden or 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
void setup(){ | |
//sets pins to OUTPUT | |
pinMode(11,OUTPUT);pinMode(10,OUTPUT);pinMode(9,OUTPUT); | |
pinMode(6,OUTPUT);pinMode(5,OUTPUT);pinMode(3,OUTPUT);} | |
// extern creates global variables | |
extern float p = 1; // phase shift constant | |
extern float s = .005; // angular velocity constant | |
extern float g = 1; // brightness threshold | |
extern int mode = 0 ; // operation mode |
This file contains hidden or 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
/* | |
PushOnce | |
Turns on and off a light emitting diode(LED) connected to digital | |
pin 13, when pressing a pushbutton attached to pin 2. | |
The circuit: | |
* LED attached from pin 13 to ground | |
* pin 2 is attached to one leg of pushbutton and to +5V through 10k resistor | |
* other leg uf pushbutton is attached to ground |
This file contains hidden or 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
/* | |
BlinkArray | |
Usses and Array structure and For and If loops to create an LED chase effect | |
This example code is in the public domain. | |
*/ | |
/* Intialize an array of LED pins | |
Define a delay called "rate" |