From 1e3d594622cfe99a50245716fdbc1b12fe0e6264 Mon Sep 17 00:00:00 2001
From: Jiawen Gong <jiawengong1112@gmail.com>
Date: Tue, 24 Oct 2023 08:20:21 +0000
Subject: [PATCH] Update file week05.md

---
 docs/assignments/week05.md | 65 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 65 insertions(+)

diff --git a/docs/assignments/week05.md b/docs/assignments/week05.md
index dd58119..69fb530 100644
--- a/docs/assignments/week05.md
+++ b/docs/assignments/week05.md
@@ -98,6 +98,71 @@ Different from digital circuit, analog signals have continuous electrical signal
 
 ## **ARDUINO**
 
+
+<iframe width="560" height="315" src="https://www.youtube.com/embed/7Q5kZ0tz3AI?si=pf0Da_Kc1y_U9K4w" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
+		
+Easiest Code for Analog Read:
+
+        // the setup routine runs once when you press reset:
+            void setup() {
+        // initialize serial communication at 9600 bits per second:
+        Serial.begin(9600);
+        }
+
+            // the loop routine runs over and over again forever:
+            void loop() {
+            // read the input on analog pin 0:
+            int sensorValue = analogRead(A0);
+            // print out the value you read:
+            Serial.println(sensorValue);
+            delay(100);  // delay in between reads for stability
+            }
+Modified Resistance Measurement Circuit (with a 9.5k ohm resistor and with custom lower and upper resistance range)
+
+    /*
+    Resistance Measurement - www.circuits4you.com
+    Reads an analog input on pin 0, converts it to resistance, and prints the result to the serial monitor.
+      Using a 9,5k ohm resistor as known resistor
+    */
+    int ledPin = 5;  // LED connected to digital pin 9
+
+        int lowerBoundResistance = 500;
+        int upperBoundResistance = 1500;
+
+        // the setup routine runs once when you press reset:
+        void setup() {
+        // initialize serial communication at 9600 bits per second:
+        Serial.begin(9600);
+        }
+
+        // the loop routine runs over and over again forever:
+        void loop() {
+        // read the input on analog pin 0:
+        int sensorValue = analogRead(A0);
+
+            // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
+            float voltage = sensorValue * (5.0 / 1024.0);
+
+            int resistorvalue = 9500; 
+            float I = voltage / resistorvalue;
+            float VRx = 5 - voltage;
+            float Rx = VRx / I;
+            Rx = (5 - voltage) / I;
+
+            int mappedValue = map(Rx, lowerBoundResistance, upperBoundResistance, 0, 255);
+            mappedValue = constrain(mappedValue, 0, 255);
+
+        // print out the value you read:
+        Serial.print("Resistance:");
+         Serial.print(Rx);
+         Serial.print(" Ohms");
+         Serial.print(" and mapped value is ");
+         Serial.println(mappedValue);
+        analogWrite(ledPin, mappedValue);
+         delay(100);
+        }
+		
+
 <div style="padding:75% 0 0 0;position:relative;"><iframe src="https://player.vimeo.com/video/877385332?badge=0&amp;autopause=0&amp;quality_selector=1&amp;progress_bar=1&amp;player_id=0&amp;app_id=58479" frameborder="0" allow="autoplay; fullscreen; picture-in-picture" style="position:absolute;top:0;left:0;width:100%;height:100%;" title="E-Textiles by Michelle Vosson"></iframe></div><script src="https://player.vimeo.com/api/player.js"></script>
 
 ## **TOOLS**
-- 
GitLab