]> 91.132.146.200 Git - arduino-sketches.git/commitdiff
adding some sketches
authorBanana <mail@bananas-playground.net>
Sun, 31 May 2026 10:05:56 +0000 (12:05 +0200)
committerBanana <mail@bananas-playground.net>
Sun, 31 May 2026 10:05:56 +0000 (12:05 +0200)
Signed-off-by: Banana <mail@bananas-playground.net>
led-segment-one/README.md [new file with mode: 0644]
led-segment-one/led-segment-one.ino [new file with mode: 0644]
sound/README.md [new file with mode: 0644]
sound/sound.ino [new file with mode: 0644]
test/test.ino [new file with mode: 0644]

diff --git a/led-segment-one/README.md b/led-segment-one/README.md
new file mode 100644 (file)
index 0000000..250e1e0
--- /dev/null
@@ -0,0 +1,30 @@
+# Single 7 segment display
+
+Set 7 segment display is a 5161AS model. It is Common-Cathode (CC)
+
+```
+Pin assignment for 5161AS
+   G  F com A  B
+ --|--|--|--|--|--
+| 10  9  8  7  6  |
+|  1  2  3  4  5  |
+ --|--|--|--|--|--
+   E  D com C  P
+```
+
+LED segments
+
+```
+    A
+   ---
+F |   | B
+   --- G
+E |   | C
+   ---  . P
+    D
+```
+
+# More infos
+https://42project.net/eine-sieben-segment-display-anzeige-direkt-mit-dem-arduino-ansteuern/#lightbox/1/
+https://vcwong.medium.com/7-segment-led-display-and-arduino-ab2982c87fe1
+https://dronebotworkshop.com/led-displays/
diff --git a/led-segment-one/led-segment-one.ino b/led-segment-one/led-segment-one.ino
new file mode 100644 (file)
index 0000000..a1cade5
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+  Pin assignment for 5161AS
+     G  F com A  B
+   --|--|--|--|--|--
+  | 10  9  8  7  6  |
+  |  1  2  3  4  5  |
+   --|--|--|--|--|--
+     E  D com C  P
+
+Segment to board pin (0 and 1 can not be used for this)
+A=2
+B=3
+C=4
+D=5
+E=6
+F=7
+G=8
+P=9
+com=GND
+
+  LED segment assignment corresponding to pins
+    A
+   ---
+F |   | B
+   --- G
+E |   | C
+   ---  . P
+    D
+*/
+
+// a list with 11 entries
+// each entry has its own 8 int (HIGH or LOW) entries
+// display a number on the 7seg is telling each segment to HIGH or LOW
+//                          A,B,C,D,E,F,G,P
+int num_array[11][8] = {  { 1,1,1,1,1,1,0,0 },  // 0
+                          { 0,1,1,0,0,0,0,0 },  // 1
+                          { 1,1,0,1,1,0,1,0 },  // 2
+                          { 1,1,1,1,0,0,1,0 },  // 3
+                          { 0,1,1,0,0,1,1,0 },  // 4
+                          { 1,0,1,1,0,1,1,0 },  // 5
+                          { 1,0,1,1,1,1,1,0 },  // 6
+                          { 1,1,1,0,0,0,0,0 },  // 7
+                          { 1,1,1,1,1,1,1,0 },  // 8
+                          { 1,1,1,0,0,1,1,0 },  // 9
+                          { 0,0,0,0,0,0,0,1}    // Dot
+};
+
+void setup() {
+    pinMode(2, OUTPUT);
+    pinMode(3, OUTPUT);
+    pinMode(4, OUTPUT);
+    pinMode(5, OUTPUT);
+    pinMode(6, OUTPUT);
+    pinMode(7, OUTPUT);
+    pinMode(8, OUTPUT);
+    pinMode(9, OUTPUT);
+
+    displayNum(2);
+}
+
+void loop() {
+    // display all the numbers
+    for(int num = 0; num < 11 ; num++) {
+        displayNum(num);
+        delay(500);
+    }
+    delay(500);
+}
+
+void displayNum(int number) {
+    int pin = 2; // the starting pin on the arduino board
+    for (int segment=0; segment < 8; segment++) {
+        digitalWrite(pin, num_array[number][segment]);
+        pin++;
+    }
+}
diff --git a/sound/README.md b/sound/README.md
new file mode 100644 (file)
index 0000000..b4f9a2d
--- /dev/null
@@ -0,0 +1,31 @@
+The idea is that using the analog or digital sound sensor reads sound changes.
+Tracks the highest value and display/store
+Or even print it with a label printer
+
+# Soundsensor
+
+Rotes rechteckiges Board. Blauer Potentiometer. Silberner Zylinder mit schwarzem Aufkleber (rau)
+4 Pins
+Rechte LED (Sensor oben, pins unten) strom
+Linke LED Anzeige wenn Ton registriert wurde.
+
+## Sensitivität einstellen:
+Potentiometer so lange nach links oder rechts drehen bis LED ausgeht.
+Darüber dann einstellen ab wann ein Signal kommen soll.
+
+Laut Beschreibung soll der Potentiometer nur für den DO sein, wenn man diesen
+einstellt ändert sich aber auch der Wert des AO.
+
+## Weitere Informationen
+
+https://arduinogetstarted.com/tutorials/arduino-sound-sensor
+https://circuitdigest.com/microcontroller-projects/interfacing-sound-sensor-with-arduino
+https://www.build-electronic-circuits.com/arduino-sound-sensor/
+https://polluxlabs.net/arduino-tutorials/einen-sound-sensor-am-arduino-verwenden/
+https://www.elektronik-kompendium.de/sites/praxis/bauteil_ky037-mikrofon.htm
+https://projecthub.arduino.cc/lakshyajhalani56/sound-sensor-arduino-project-sound-sensor-module-arduino-31a654
+https://sensorkit.arduino.cc/sensorkit/module/lessons/lesson/06-the-sound-sensor
+https://wiki.seeedstudio.com/Grove-Sound_Sensor/
+
+Chipset PDF
+https://www.onsemi.com/pdf/datasheet/lm358-d.pdf
diff --git a/sound/sound.ino b/sound/sound.ino
new file mode 100644 (file)
index 0000000..6c14aea
--- /dev/null
@@ -0,0 +1,33 @@
+#define ANALOG_IN A0
+
+void setup() {
+    Serial.begin(9600); // initialize serial communication at 9600 bits per second
+    pinMode(ANALOG_IN, INPUT);
+}
+
+int soundPeak = 0;
+unsigned long previousMillis = 0;
+const long resetAfterMillis = 5000;
+
+void loop() {
+    int soundValue = 0; //create variable to store many different readings
+    unsigned long currentMillis = millis();
+
+    for (int i = 0; i < 32; i++) {
+        soundValue += analogRead(ANALOG_IN);
+    }
+
+    soundValue >>= 5; //bitshift operation
+
+    if(soundValue > soundPeak) {
+        soundPeak = soundValue;
+    }
+
+    if (currentMillis - previousMillis >= resetAfterMillis) {
+        previousMillis = currentMillis;
+        Serial.println(soundPeak);
+        soundPeak = 0;
+    }
+
+    delay(50);
+}
diff --git a/test/test.ino b/test/test.ino
new file mode 100644 (file)
index 0000000..86a4801
--- /dev/null
@@ -0,0 +1,11 @@
+
+void setup() {
+    pinMode(LED_BUILTIN, OUTPUT);
+}
+
+void loop() {
+    digitalWrite(LED_BUILTIN, HIGH);
+    delay(1000);
+    digitalWrite(LED_BUILTIN, LOW);
+    delay(1000);
+}