commit 4b7db472bcf2bb208d9b87ecfcc56af710aa5eeb
parent 4036e1cb1eab1b531bd2b5f1108d99cdb8bba88a
Author: thing1 <thing1@seacrossedlovers.xyz>
Date: Thu, 20 Nov 2025 17:39:14 +0000
added support for the IR stuff
Diffstat:
3 files changed, 24 insertions(+), 0 deletions(-)
diff --git a/CS12020/robot/line/helper.h b/CS12020/robot/line/helper.h
@@ -18,6 +18,11 @@
#define SERVOB_ZERO 96
#define ANALOG_MAX 1023
+#define IRTRANSMITTER 3
+#define IRRECEVIER 2
+
+#define IRFREQ 38000
+
#define LDRA_SWITCH (ANALOG_MAX / 2) + 100
#define LDRB_SWITCH (ANALOG_MAX / 2) + 100
#define LDRC_SWITCH (ANALOG_MAX / 2) + 50
@@ -47,12 +52,23 @@ setupRobot() {
pinMode(LDRA, INPUT);
pinMode(LDRB, INPUT);
pinMode(LDRC, INPUT);
+ pinMode(IRTRANSMITTER, OUTPUT);
+ pinMode(IRRECEVIER, INPUT);
servoA.attach(SERVOA_PIN);
servoB.attach(SERVOB_PIN);
servoA.write(SERVOA_ZERO);
servoB.write(SERVOB_ZERO);
}
+
+bool
+isObstacle() {
+ tone(IRTRANSMITTER, IRFREQ);
+ bool ret = (digitalRead(IRRECEVIER) == LOW);
+ noTone(IRTRANSMITTER);
+ return ret;
+}
+
bool
isLDRBright(int pin) {
int v = analogRead(pin);
diff --git a/CS12020/robot/line/line.ino b/CS12020/robot/line/line.ino
@@ -105,6 +105,8 @@ setup() {
}
void loop() {
+ setLEDs(LOW, LOW, isObstacle());
+ return;
state *s = getState();
if (s->right && s->left && s->mid) {
diff --git a/PH16210/20.11.25.md b/PH16210/20.11.25.md
@@ -0,0 +1,6 @@
+20/11/25
+========
+
+- see FIG1 for notation, that lets us use the time derivative as an algebraic term
+- see FIG2 for method to solve 2nd order ODE's
+ - this is only valid if both the roots are real in the quadratic