uni

Thing1's amazing uni repo
Log | Files | Refs

commit e8cf90bd263022333d81e666d3b190f95a525d21
parent 2fb26131534cb809a7c4aa5696b482907e88ae55
Author: thing1 <thing1@seacrossedlovers.xyz>
Date:   Tue, 18 Nov 2025 12:54:43 +0000

lectures and lab

Diffstat:
ACS12020/17.11.25.md | 4++++
MCS12020/robot/line/helper.h | 4++--
MCS12020/robot/line/line.ino | 55+++++++++++++++++++++++++++++++++++++------------------
ACS18120/18.11.25.md | 4++++
APH16210/17.11.25.md | 5+++++
5 files changed, 52 insertions(+), 20 deletions(-)

diff --git a/CS12020/17.11.25.md b/CS12020/17.11.25.md @@ -0,0 +1,4 @@ +17/11/25 +======== + +- structs are cool diff --git a/CS12020/robot/line/helper.h b/CS12020/robot/line/helper.h @@ -108,8 +108,8 @@ readint() { void stepMove(int dir) { - servoA.write(SERVOA_ZERO + (10 * dir)); - servoB.write(SERVOB_ZERO - (10 * dir)); + servoA.write(SERVOA_ZERO + (6 * dir)); + servoB.write(SERVOB_ZERO - (6 * dir)); delay(10); servoA.write(SERVOA_ZERO); servoB.write(SERVOB_ZERO); diff --git a/CS12020/robot/line/line.ino b/CS12020/robot/line/line.ino @@ -1,9 +1,31 @@ #include "helper.h" int prevDir = BWD; -long timeSinceBar = 0; -long barcode = 0; -bool hasSeenBar = false; +long timeStamp = 0; + +void +stepAvoidanceBehave() { + int left = analogRead(LDRA), + mid = analogRead(LDRB), + right = analogRead(LDRC); + + if (mid > left - 300 && mid > right - 300) + stepMove(BWD); + stepTurn((left > right) ? RGT : LFT); +} + +void +stepAttractionBehave() { + int left = analogRead(LDRA), + mid = analogRead(LDRB), + right = analogRead(LDRC); + + if (mid > left - 300 && mid > right - 300) + stepMove(FWD); + + stepTurn((left < right) ? RGT : LFT); +} + void setup() { @@ -17,26 +39,23 @@ void loop() { mid = !isLDRBright(LDRB), right = !isLDRBright(LDRC); - if (right && left && mid) { - if (hasSeenBar) { - if (millis() - barcode > 3000) { + if (right && left && mid) { /* on barcode */ + if (timeStamp > 500) { + if ((millis() - timeStamp) > 3000) { /* long barcode */ setLEDs(LOW, HIGH, LOW); - delay(100000); - } else if (millis() - barcode > 800) { - setLEDs(HIGH, LOW, LOW); - delay(100000); + while (1) + stepAvoidanceBehave(); + } + else if ((millis() - timeStamp) > 800) { /* short barcode */ + setLEDs(HIGH, LOW, HIGH); + while (1) + stepAvoidanceBehave(); } } - if (timeSinceBar) - barcode = timeSinceBar; - timeSinceBar = millis() - timeSinceBar; + timeStamp = millis(); for (int i = 0; i < 20; i++) stepMove(FWD); - return; - } else if (barcode) { - hasSeenBar = true; - } - + } if (right && mid) stepLFT(); diff --git a/CS18120/18.11.25.md b/CS18120/18.11.25.md @@ -0,0 +1,4 @@ +18/11/25 +======== + +- latex cool (we already knew this) diff --git a/PH16210/17.11.25.md b/PH16210/17.11.25.md @@ -0,0 +1,5 @@ +17/11/25 +======== + +- Orthogonal means that 2 curves tangents are right angles to eachother + - See fig1 for a rule for this