Browse Source

Test program for a LDR input with mapped values

master
Max Lehmann 3 years ago
parent
commit
db482f23ef
1 changed files with 21 additions and 0 deletions
  1. 21
    0
      sketches/max_sketch/LDR_Test_1/LDR_Test_1.ino

+ 21
- 0
sketches/max_sketch/LDR_Test_1/LDR_Test_1.ino View File

@@ -0,0 +1,21 @@
1
+#define IN3 (A3)
2
+int VAL3;
3
+int MAP3;
4
+int CONST;
5
+
6
+void setup() {
7
+Serial.begin(9600);
8
+}
9
+
10
+void loop() {
11
+VAL3=analogRead(IN3);
12
+Serial.print(VAL3);
13
+MAP3 = map(VAL3, 70, 500, 10, 1200);
14
+CONST = constrain(MAP3, 1, 1200);
15
+tone(11, CONST);
16
+Serial.print("\t");
17
+Serial.print(MAP3);
18
+Serial.print("\t");
19
+Serial.println(CONST);
20
+//delay(50);
21
+}

Loading…
Cancel
Save