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
| const int SENSOR = A0; // select the input pin for the | |
| // sensor resistor | |
| int val = 0; // variable to store the value coming | |
| // from the sensor | |
| void setup() { | |
| Serial.begin(9600); // open the serial port to send | |
| // data back to the computer at | |
| // 9600 bits per second | |
| } | |
| void loop() { |
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
| const int LED = 9; // the pin for the LED | |
| int val = 0; // variable used to store the value coming from the sensor | |
| void setup() { | |
| pinMode(LED, OUTPUT); // LED is as an OUTPUT | |
| } | |
| void loop() { | |
| val = analogRead(0); // read the value from | |
| // the sensor |
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
| const int LED = 9; // the pint for the LED | |
| const int BUTTON = 7; // input pin of the pushbutton | |
| int val = 0; //stores the state of the input pin | |
| int old_val = 0; //stores the previous value of "val" | |
| int state = 0; //0 = LED off while 1 = LED on | |
| int brightness = 128; //stores the brightness value | |
| unsigned long startTime = 0; //wjem dod we begin pressing? |
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
| const int REDLED = 13; // the pin for the LED | |
| const int YELLOWLED = 12; | |
| const int GREENLED = 11; | |
| const int BUTTON = 7; // the input pin where the pushbutton is connected | |
| int val = 0; // val will be used to store the state of the input pin | |
| int state = 0; // 0 = LED off and 1 = LED on | |
| void 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
| // Blinking LED | |
| const int LED = 13; // LED connected to digital pin 13 | |
| void setup() { | |
| pinMode(LED, OUTPUT); // Sets digital pin as output | |
| } | |
| void loop() { |
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
| dir *= -1; | |
| on_time = interval - dead_time; | |
| } | |
| else if (on_time <= 0) { | |
| on_time = 0; | |
| dir *= -1; | |
| LED_tracker1 = LED_tracker2; | |
| while (LED_tracker1 == LED_tracker2) LED_tracker1 = random(1,10); | |
| offset2 = random(0,4000); | |
| } |
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
| // initialize serial communication at 9600 bps | |
| int lightSensorValue = 0; | |
| int lightSensorPin = A2; | |
| int greenLEDPin = 9; // LED connected to digital pin 9 | |
| int redLEDPin = 10; // LED connected to digital pin 10 | |
| int redValue = 0; // value to write to the red LED | |
| int greenValue = 0; // value to write to the green LED | |
| void setup() { | |
| Serial.begin(9600); |