Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Magestaff v0.0001
- Simon Smedja
- 2015.05.18
- */
- //pin numbers:
- const int buttonPin1 = 2;
- const int buttonPin2 = 3;
- const int buttonPin3 = 4;
- const int ledPin1 = 5;
- const int ledPin2 = 6;
- const int ledPin3 = 7;
- // variables
- int buttonState1 = 0;
- int buttonState2 = 0;
- int buttonState3 = 0;
- void setup() {
- // initialize the LED pins as outputs:
- pinMode(ledPin1, OUTPUT);
- pinMode(ledPin2, OUTPUT);
- pinMode(ledPin3, OUTPUT);
- // initialize the pushbutton pins as inputs:
- pinMode(buttonPin1, INPUT);
- pinMode(buttonPin2, INPUT);
- pinMode(buttonPin3, INPUT);
- }
- void loop(){
- // read the state of a pushbutton value:
- buttonState1 = digitalRead(buttonPin1);
- buttonState2 = digitalRead(buttonPin2);
- buttonState3 = digitalRead(buttonPin3);
- // check if a pushbutton is pressed.
- if (buttonState1 == HIGH) {
- // turn LED on:
- digitalWrite(ledPin1, HIGH);
- }
- else {
- // turn LED off:
- digitalWrite(ledPin1, LOW);
- }
- if (buttonState2 == HIGH) {
- // turn LED on:
- digitalWrite(ledPin2, HIGH);
- }
- else {
- // turn LED off:
- digitalWrite(ledPin2, LOW);
- }
- // Storbe sequence, might control a transistor to run a stronger pair of leds
- if (buttonState3 == HIGH) {
- // turn LED on:
- digitalWrite(ledPin3, HIGH);
- delay(50); //wait 50 milliseconds
- digitalWrite(ledPin3, LOW);
- delay(50);
- digitalWrite(ledPin3, HIGH);
- delay(50);
- digitalWrite(ledPin3, LOW);
- delay(50);
- digitalWrite(ledPin3, HIGH);
- delay(50);
- digitalWrite(ledPin3, LOW);
- delay(50);
- digitalWrite(ledPin3, HIGH);
- delay(50);
- digitalWrite(ledPin3, LOW);
- delay(50);
- digitalWrite(ledPin3, HIGH);
- delay(2000); //wait and be HIGH for 2000 milliseconds
- digitalWrite(ledPin3, LOW);
- delay(50);
- digitalWrite(ledPin3, HIGH);
- delay(50);
- digitalWrite(ledPin3, LOW);
- delay(50);
- }
- else {
- // turn LED off:
- digitalWrite(ledPin3, LOW);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement