aboutsummaryrefslogtreecommitdiff
path: root/Code from circuits/Alarm
diff options
context:
space:
mode:
authorSyndamia <kamen.d.mladenov@protonmail.com>2020-06-23 22:52:36 +0300
committerSyndamia <kamen.d.mladenov@protonmail.com>2020-06-23 22:52:36 +0300
commit8a55a9810c2ae2f8d00be456d9c7295dd44c7509 (patch)
tree1682f75632f10eede9c86030080f6cd896eabff9 /Code from circuits/Alarm
parent40e0d86c1364b1f0c2395a42c5e1b49730b7e31e (diff)
downloadRemiHap-8a55a9810c2ae2f8d00be456d9c7295dd44c7509.tar
RemiHap-8a55a9810c2ae2f8d00be456d9c7295dd44c7509.tar.gz
RemiHap-8a55a9810c2ae2f8d00be456d9c7295dd44c7509.zip
Fixed inconsistent/bad formatting in Alarm microcontroller code
Diffstat (limited to 'Code from circuits/Alarm')
-rw-r--r--Code from circuits/Alarm/Alarm.ino71
1 files changed, 34 insertions, 37 deletions
diff --git a/Code from circuits/Alarm/Alarm.ino b/Code from circuits/Alarm/Alarm.ino
index 7ad8a31..44fed37 100644
--- a/Code from circuits/Alarm/Alarm.ino
+++ b/Code from circuits/Alarm/Alarm.ino
@@ -1,24 +1,25 @@
#include <Adafruit_NeoPixel.h>
+//Defining the notes' frequencies for the melody
#define NOTE_C5 523
#define NOTE_D5 587
#define NOTE_E5 659
-//Defining the notes' frequencies for the melody
-#define interval 10000
//Time in millisecconds between first and second alarm
+#define interval 10000
#define BTN_PIN 2
#define STRIP_PIN 3
-#define LED_COUNT 4
#define PIEZZO_PIN 5
+#define LED_COUNT 4
+
#define MELODY_LENGTH 4
int melodies[2][MELODY_LENGTH] =
{
- {NOTE_C5, NOTE_E5, NOTE_D5, 0},
- {NOTE_C5, NOTE_C5, NOTE_C5, NOTE_C5}
+ { NOTE_C5, NOTE_E5, NOTE_D5, 0 },
+ { NOTE_C5, NOTE_C5, NOTE_C5, NOTE_C5 }
};
int noteDurations[] =
@@ -37,32 +38,31 @@ bool ButtonIsPressed()
void ledToggle()
{
if(strip.getPixelColor(0) == strip.Color(0,0,0))
- {
- strip.fill(color);
- }
- else
- {
- strip.clear();
- }
- strip.show();
+ {
+ strip.fill(color);
+ }
+ else
+ {
+ strip.clear();
+ }
+ strip.show();
}
void playNote(int noteDuration, int noteToPlay)
{
- tone(PIEZZO_PIN, noteToPlay, noteDuration);
- delay(noteDuration * 1.30);
+ tone(PIEZZO_PIN, noteToPlay, noteDuration);
+ delay(noteDuration * 1.30);
- noTone(PIEZZO_PIN);
+ noTone(PIEZZO_PIN);
}
void PlayMelodyAndLEDs(int position)
{
- for(int i = 0; i < MELODY_LENGTH; i++)
+ for(int i = 0; i < MELODY_LENGTH; i++)
{
- playNote(noteDurations[i], melodies[position][i]);
- ledToggle();
- delay(100);
-
+ playNote(noteDurations[i], melodies[position][i]);
+ ledToggle();
+ delay(100);
}
}
@@ -76,23 +76,21 @@ void setup()
void Alarm(unsigned long timeSinceActivation)
{
- while(ButtonIsPressed())
- {
- if(millis() - timeSinceActivation > interval)
- {
- color = strip.Color(255, 0, 0);
- PlayMelodyAndLEDs(1);
- }
- else
- {
- color = strip.Color(255, 255, 0);
- PlayMelodyAndLEDs(0);
- }
- }
+ while(ButtonIsPressed())
+ {
+ if(millis() - timeSinceActivation > interval)
+ {
+ color = strip.Color(255, 0, 0);
+ PlayMelodyAndLEDs(1);
+ }
+ else
+ {
+ color = strip.Color(255, 255, 0);
+ PlayMelodyAndLEDs(0);
+ }
+ }
}
-
-
void loop()
{
if(ButtonIsPressed())
@@ -101,4 +99,3 @@ void loop()
}
delay(100);
}
-