Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const int ledPin = LED_BUILTIN;
- int ledState = LOW;
- unsigned long previuosTime = 0;
- const long interval = 1000;
- const int ledOnePin = 12;
- const int ledTwoPin = 8;
- const int buttonOnePin = 2;
- int buttonOneState = 0; // variable for reading the pushbutton status
- #include "pitches.h";
- const int buzzerPin = 7;
- const int buttonTwoPin = 4;
- const int ledThreePin = 10;
- int buttonTwoState = 0;
- int melody[] = {
- NOTE_C4, NOTE_G3, NOTE_G3, NOTE_A3, NOTE_G3, 0, NOTE_B3, NOTE_C4
- };
- int durations[] = {
- 4, 8, 8, 4, 4, 4, 4, 4 // 4 = quarter note, 8 = eighth note, etc.
- };
- void setup() {
- Serial.begin(9600); // initialize serial communication at 9600 bits per second:
- pinMode(ledPin, OUTPUT);
- pinMode(buttonOnePin, INPUT);
- pinMode(ledOnePin, OUTPUT);
- pinMode(ledTwoPin, OUTPUT);
- pinMode(buttonTwoPin, INPUT);
- pinMode(ledThreePin, OUTPUT);
- }
- void loop() {
- // put your main code here, to run repeatedly:
- buttonOneState = digitalRead(buttonOnePin);
- if (buttonOneState == HIGH) {
- digitalWrite(ledOnePin, buttonOneState);
- digitalWrite(ledTwoPin, LOW);
- Serial.println("ledOne ON +++");
- } else {
- digitalWrite(ledOnePin, buttonOneState);
- digitalWrite(ledTwoPin, HIGH);
- Serial.println("ledOne OFF ---");
- }
- buttonTwoState = digitalRead(buttonTwoPin);
- digitalWrite(ledThreePin, buttonTwoState); // red light mother fucker
- if (buttonTwoState == HIGH){
- digitalWrite(ledTwoPin, LOW); // :)
- digitalWrite(ledOnePin, LOW); // :)
- for (int thisNote=0; thisNote<8; thisNote++){
- int noteDuration = 1000/durations[thisNote];
- tone(buzzerPin, melody[thisNote], noteDuration);
- int pauseBetweenNotes = noteDuration * 1.30;
- delay(pauseBetweenNotes);
- noTone(buzzerPin);
- }
- }
- //end of regular code
- unsigned long currentTime = millis();
- if (currentTime - previuosTime >= interval){
- previuosTime = currentTime;
- if (ledState == LOW) {
- ledState = HIGH;
- Serial.println("IIIIIIIIIIIIIIIIIIIII on IIIIIIIIIIIIIIIIIIIII");
- } else {
- ledState = LOW;
- }
- digitalWrite(ledPin, ledState);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement