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
//Blink code: | |
// int is type of variable. variables are where we store information. | |
// here we store the name of our LED pin. | |
int led = 13; | |
// another variable as an example. | |
int blinks; | |
// the setup routine runs once in the beginning. |
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 led = 13; | |
int led2 = 11; | |
int blinks; | |
// the setup routine runs once when you press reset: | |
void setup() { | |
// initialize the digital pin as an output. | |
pinMode(led, OUTPUT); | |
pinMode(led2, OUTPUT); | |
Serial.begin(9600); | |
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 led = 13; | |
int led2 = 11; | |
int blinks; | |
int fade; | |
// the setup routine runs once when you press reset: | |
void setup() { | |
// initialize the digital pin as an output. | |
pinMode(led, OUTPUT); | |
pinMode(led2, OUTPUT); | |
Serial.begin(9600); |
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
//Blinking and Fading | |
int led = 13; | |
int led2 = 11; | |
// This time the fade variable is a byte instead of an int. | |
byte fade; | |
// A big variable to keep track of the timer. | |
long timer; |
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
//Light Sensor Code | |
int led = 13; | |
int led2 = 11; | |
byte fade; | |
long timer; | |
long previousTimer; | |
int ledState = LOW; |
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
// Block Diagram | |
// +---------------------+ | |
// | State 0: | | |
// | Check light sensor | | |
// | If it is dark: <---+ | |
// | - Turn on light | | | |
// | - Change State to 1 | | | |
// | - Remember the time | | | |
// +---------+-----------+ | | |
// | | |
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
// Block Diagram | |
// +---------------------+ | |
// | State 0: | | |
// | Check light sensor | | |
// | If it is dark: <---+ | |
// | - Turn on light | | | |
// | - Change State to 1 | | | |
// | - Remember the time | | | |
// +---------+-----------+ | | |
// | | |
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
// | |
// +--------+ | |
// | TOUCH | | |
// | SENSOR | | |
// | | | |
// +------ | | |
// ARDUINO | | |
// +-----------+ | | |
// | GND|-----------------+ | | |
// | | | | |
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 timer = 60; // The higher the number, the slower the timing. | |
int ledPins[] = { | |
11, 10, 9, 6, 5, 3 }; // an array of pin numbers to which LEDs are attached | |
int pinCount = 6; // the number of pins (i.e. the length of the array) | |
void setup() { | |
// the array elements are numbered from 0 to (pinCount - 1). | |
// use a for loop to initialize each pin as an output: | |
for (int thisPin = 0; thisPin < pinCount; thisPin++) { |
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 ledPins[] = { | |
11, 10, 9, 6, 5, 3 }; | |
int pinCount = 6; | |
int lightPin = A0; // A variable for which pin has the light sensor. | |
int lightValue = 0; // A variable to keep track of the value we get from the light sensor. | |
int aLED = 13; | |
boolean aLEDstate; |