<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Assignment 6 &#8211; Making Things Interactive, Spring 2022</title>
	<atom:link href="https://courses.ideate.cmu.edu/48-339/s2022/?feed=rss2&#038;cat=15" rel="self" type="application/rss+xml" />
	<link>https://courses.ideate.cmu.edu/48-339/s2022</link>
	<description>Making Things Interactive</description>
	<lastBuildDate>Mon, 04 Apr 2022 20:11:43 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.8.9</generator>
	<item>
		<title>Assignment 6 Update</title>
		<link>https://courses.ideate.cmu.edu/48-339/s2022/?p=2315</link>
					<comments>https://courses.ideate.cmu.edu/48-339/s2022/?p=2315#respond</comments>
		
		<dc:creator><![CDATA[eperceva@andrew.cmu.edu]]></dc:creator>
		<pubDate>Sun, 27 Feb 2022 02:42:20 +0000</pubDate>
				<category><![CDATA[Assignment 6]]></category>
		<guid isPermaLink="false">https://courses.ideate.cmu.edu/48-339/s2022/?p=2315</guid>

					<description><![CDATA[With the wires back on the fan motor, I confirmed that code works in two ways: 1) when the humidity sensor detects that the average humidity is less than 50% the fan turns on, and 2) when the average humidity is less than 50% the fan turns off. Next, with condition 2 as the base &#8230; <a href="https://courses.ideate.cmu.edu/48-339/s2022/?p=2315" class="more-link">Continue reading<span class="screen-reader-text"> "Assignment 6 Update"</span></a>]]></description>
										<content:encoded><![CDATA[<p>With the wires back on the fan motor, I confirmed that code works in two ways: 1) when the humidity sensor detects that the average humidity is less than 50% the fan turns on, and 2) when the average humidity is less than 50% the fan turns off. Next, with condition 2 as the base conditions, I needed to test if the fan will turn on when the humidity sensor detects that the average humidity has increased to above 50%.</p>
<p>With my first version of the code, the fan was not responding the way I wanted to the humidity sensor readings.</p>
<p>This second version of the code using millis() was successful:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic">#include &lt;DHT.h&gt;
#include &lt;DHT_U.h&gt;
#define DHTPIN 2        // sensor DHT22 data connected to Arduino pin 2
#define DHTTYPE DHT22  // using sensor DHT22
DHT dht(DHTPIN, DHTTYPE);  //dht library
int chk;
int humid; //stores humidity


//data smoothing
const int numReadings = 5;
int humReadings [numReadings];
int humReadIndex = 0;
int humTotal = 0;
int humAverage = 0;
int inputPin = 2; //put dht 222 sensor pin here
//detecting sensor change
int last;
//response to sensor change


//for fan and motor
int speedPin = 5;
int dir1 = 4;
int dir2 = 3;
int mSpeed = 0;
unsigned long lastReadTime = 0;

void setup() {
  // put your setup code here, to run once:
  //pins for fan and motot
  pinMode(speedPin, OUTPUT);
  pinMode(dir1, OUTPUT);
  pinMode(dir2, OUTPUT);


  //dht sensor
  dht.begin();

//data smoothing for humidity
  for (int thisReading = 0; thisReading &lt; numReadings; thisReading++) {
    //tempReadings[thisReading] = 0;
    humReadings[thisReading] = 0;
  }
  Serial.begin(9600);

  lastReadTime = millis();
}

void loop() {
  //delay(1000);

  if ((millis() - lastReadTime) &gt;= 10000UL) {
    //Serial.println(lastReadTime); //used to check millis 
    //Serial.println(millis());//used to check millis
    lastReadTime = millis();
    humid = dht.readHumidity();
    Serial.println(humid); //prints the current sensor reading
    humTotal = humTotal - humReadings[humReadIndex];
    humReadings[humReadIndex] = humid;
    humTotal = humTotal + humReadings [humReadIndex];
    humReadIndex = humReadIndex + 1;
    if (humReadIndex &gt;= numReadings) {
      humReadIndex = 0;
    }
    humAverage = humTotal / numReadings;
    Serial.println(humAverage);

  }


  if (humAverage &gt; 50)
  {
    digitalWrite(dir1, HIGH);
    digitalWrite(dir2, LOW);
    analogWrite(speedPin, 225);
  }else
  {
    digitalWrite(dir1,HIGH);
    digitalWrite(dir2,LOW);
    analogWrite(speedPin, 0);
  }
}</pre>
<p>I started in a room with humidity readings less than 50 (no fan motion). I turned on hot water in the bathroom, and after a few minutes, moved the sensor and fan into that room. As the sensor&#8217;s humidity reading rose, so did the average humidity reading. Once the average humidity reading rose above 50, the fan began to turn. Then I moved the sensor and fan back into the original room, and waited for the average humidity to fall. When the average humidity fell below 50 again, the fan motor turned off.</p>
<p>Note on power and troubleshooting:</p>
<p>I originally had both the fan and the humidity sensor connected to the rail. This worked the first time I tried it, but the sensor began to send back 0 readings after a few test runs. I had to connect the DHT22 sensor to the arduino and the fan to the rail (with 5V power supply connected to 9V battery) for both the sensor and the fan to work properly. My clue was that the LED light on the power supply started bright and dimmed as the code started running.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://courses.ideate.cmu.edu/48-339/s2022/?feed=rss2&#038;p=2315</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Assignment 6 &#8211; Jud</title>
		<link>https://courses.ideate.cmu.edu/48-339/s2022/?p=2307</link>
					<comments>https://courses.ideate.cmu.edu/48-339/s2022/?p=2307#respond</comments>
		
		<dc:creator><![CDATA[judsonk@andrew.cmu.edu]]></dc:creator>
		<pubDate>Tue, 22 Feb 2022 03:19:28 +0000</pubDate>
				<category><![CDATA[Assignment 6]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<guid isPermaLink="false">https://courses.ideate.cmu.edu/48-339/s2022/?p=2307</guid>

					<description><![CDATA[Description: This circuit turns the data that the sound sensor gets into an angle based off of a moving average of the amplitude of the data received. The data from the sensor captures the raw sound waves from the air and sends them to the arduino which has a very spiky and unsmooth nature. In &#8230; <a href="https://courses.ideate.cmu.edu/48-339/s2022/?p=2307" class="more-link">Continue reading<span class="screen-reader-text"> "Assignment 6 &#8211; Jud"</span></a>]]></description>
										<content:encoded><![CDATA[<h3>Description:</h3>
<p>This circuit turns the data that the sound sensor gets into an angle based off of a moving average of the amplitude of the data received. The data from the sensor captures the raw sound waves from the air and sends them to the arduino which has a very spiky and unsmooth nature. In addition, the data transitions for increasing to decreasing very rapidly so a traditional filter or tracking the change in the data does not work well at all. Instead, I have implemented a moving average method where the code tracks a certain number of data points, calculates the max and min of the data, and then uses the difference between these values as the new data. This is then multiplied by some multiplier to increase the variance and translated into an angle for a servo to travel to. The algorithm for calculating the angle works wonders while the servo isn&#8217;t connected, however, as depicted in the video, the noise of the servo creates an uncontrollable feedback look that results in the servo moving out of control. Regardless, the system responds to noise in the way that it should translating a noise in the environment into an angle for the servo to move to.</p>
<h3>Video:</h3>
<div style="width: 840px;" class="wp-video"><!--[if lt IE 9]><script>document.createElement('video');</script><![endif]-->
<video class="wp-video-shortcode" id="video-2307-1" width="840" height="473" preload="metadata" controls="controls"><source type="video/mp4" src="https://courses.ideate.cmu.edu/48-339/s2022/wp-content/uploads/2022/02/Assignment_5_demo.mp4?_=1" /><a href="https://courses.ideate.cmu.edu/48-339/s2022/wp-content/uploads/2022/02/Assignment_5_demo.mp4">https://courses.ideate.cmu.edu/48-339/s2022/wp-content/uploads/2022/02/Assignment_5_demo.mp4</a></video></div>
<h3>Code:</h3>
<pre class="EnlighterJSRAW" data-enlighter-language="c" data-enlighter-theme="eclipse">#include &lt;Servo.h&gt;

//Define Accelerometer Variables for pins
#define MICROPHONE    A0
#define SERVO_PIN     9

Servo servo;

double servoAngle = 0;

double alpha = 0.9;
double multiplier = 5;

//Array to hold data for moving average calculation
double speakerData[100]; // {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}

double speakerLevel = 0;
double prevSpeakerLevel = 0;
double maxSpeakerLevel = 200;
double minSpeakerLevel = 50;


void setup() {
  //Setup pins as inputs
  pinMode(MICROPHONE, INPUT);

  //Create servo object
  servo.attach(SERVO_PIN);
  
}

void loop() {

  //Update moving average array
  for (int i = (sizeof(speakerData)/sizeof(speakerData[0]) - 1); i &gt;= 0; i--) {
    if (i != 0) {
      speakerData[i] = speakerData[i - 1];
    }
    else {
      speakerData[i] = analogRead(MICROPHONE);
    }
  }

  double MIN = findMin();
  double MAX = findMax();

  speakerLevel = MAX - MIN;
  speakerLevel = multiplier*(alpha*speakerLevel + (1 - alpha)*prevSpeakerLevel);  //Filter data

  //Put upper and lower bounds on data
  if (speakerLevel &gt;= maxSpeakerLevel) {
    speakerLevel = maxSpeakerLevel;
  }
  else if (speakerLevel &lt;= minSpeakerLevel) {
    speakerLevel = minSpeakerLevel;
  }

  servoAngle = 180*(speakerLevel - minSpeakerLevel)/(maxSpeakerLevel - minSpeakerLevel);
  servo.write((int) servoAngle);

  prevSpeakerLevel = speakerLevel;
  
}

int findMin() {
  double minimum = 0;
  for (int i = 0; i &lt; sizeof(speakerData)/sizeof(speakerData[0]); i++) {
    if (speakerData[i] &lt; minimum || i == 0) {
      minimum = speakerData[i];
    }
  }
  return minimum;
}

int findMax() {
  double maximum = 0;
  for (int i = 0; i &lt; sizeof(speakerData)/sizeof(speakerData[0]); i++) {
    if (speakerData[i] &gt; maximum) {
      maximum = speakerData[i];
    }
  }
  return maximum;
}
</pre>
<p>&nbsp;</p>
]]></content:encoded>
					
					<wfw:commentRss>https://courses.ideate.cmu.edu/48-339/s2022/?feed=rss2&#038;p=2307</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		<enclosure url="https://courses.ideate.cmu.edu/48-339/s2022/wp-content/uploads/2022/02/Assignment_5_demo.mp4" length="15563903" type="video/mp4" />

			</item>
		<item>
		<title>Assignment 6 &#8211; James Kyle</title>
		<link>https://courses.ideate.cmu.edu/48-339/s2022/?p=2300</link>
					<comments>https://courses.ideate.cmu.edu/48-339/s2022/?p=2300#respond</comments>
		
		<dc:creator><![CDATA[jkyle1@andrew.cmu.edu]]></dc:creator>
		<pubDate>Tue, 22 Feb 2022 02:28:44 +0000</pubDate>
				<category><![CDATA[Assignment 6]]></category>
		<guid isPermaLink="false">https://courses.ideate.cmu.edu/48-339/s2022/?p=2300</guid>

					<description><![CDATA[Daylight Level Indicator: For this assignment, I have made a theoretical daylight level sensor. The inspiration for this comes from my lab being in the basement of Ansys. We have no windows down there so I can easily get sucked into work and stay there for hours without realizing what time of day it is &#8230; <a href="https://courses.ideate.cmu.edu/48-339/s2022/?p=2300" class="more-link">Continue reading<span class="screen-reader-text"> "Assignment 6 &#8211; James Kyle"</span></a>]]></description>
										<content:encoded><![CDATA[<p><span style="text-decoration: underline"><strong>Daylight Level Indicator:</strong></span></p>
<p>For this assignment, I have made a theoretical daylight level sensor. The inspiration for this comes from my lab being in the basement of Ansys. We have no windows down there so I can easily get sucked into work and stay there for hours without realizing what time of day it is and/or whether it is time to pack up and call it a day. This daylight level indicator is meant to solve this problem by sensing the amount of daylight coming from outside and physically turning a dial to show the time of day. Theoretically, this dial would take the shape of a circle with night and day images on either side. The servo would turn to the appropriate position to indicate how close the sun is to setting or rising depending on the level of light outside and the time of day.</p>
<div style="width: 840px;" class="wp-video"><video class="wp-video-shortcode" id="video-2300-2" width="840" height="1493" preload="metadata" controls="controls"><source type="video/mp4" src="https://courses.ideate.cmu.edu/48-339/s2022/wp-content/uploads/2022/02/IMG_7377.mp4?_=2" /><a href="https://courses.ideate.cmu.edu/48-339/s2022/wp-content/uploads/2022/02/IMG_7377.mp4">https://courses.ideate.cmu.edu/48-339/s2022/wp-content/uploads/2022/02/IMG_7377.mp4</a></video></div>
<p><img loading="lazy" class="alignnone  wp-image-2304" src="https://courses.ideate.cmu.edu/48-339/s2022/wp-content/uploads/2022/02/DaylightSensor_Fritzing-300x241.jpg" alt="" width="748" height="601" srcset="https://courses.ideate.cmu.edu/48-339/s2022/wp-content/uploads/2022/02/DaylightSensor_Fritzing-300x241.jpg 300w, https://courses.ideate.cmu.edu/48-339/s2022/wp-content/uploads/2022/02/DaylightSensor_Fritzing-1024x823.jpg 1024w, https://courses.ideate.cmu.edu/48-339/s2022/wp-content/uploads/2022/02/DaylightSensor_Fritzing-768x617.jpg 768w, https://courses.ideate.cmu.edu/48-339/s2022/wp-content/uploads/2022/02/DaylightSensor_Fritzing-1536x1234.jpg 1536w, https://courses.ideate.cmu.edu/48-339/s2022/wp-content/uploads/2022/02/DaylightSensor_Fritzing-1200x964.jpg 1200w, https://courses.ideate.cmu.edu/48-339/s2022/wp-content/uploads/2022/02/DaylightSensor_Fritzing.jpg 1755w" sizes="(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px" /></p>
<pre class="EnlighterJSRAW" data-enlighter-language="cpp">#include &lt;Servo.h&gt;


int hours = 0;

const int measurementNumber = 20;
int measurementCount = 0;
int lightMeasurements[measurementNumber];
const int lightLevel = A0; //Light level pin (photoresistor pin)

int lightBottomBound = 0;
int lightTopBound = 0;


Servo myServo;
int SERVOPIN = 9;



void setup() {

  pinMode(lightLevel, INPUT);

  myServo.attach(9);

}

void loop() {

  //Update measurement counter
  if (measurementCount &lt; measurementNumber) {
    measurementCount += 1;
  } else {
    measurementCount = 0;
  }


  //Update light level average
  int lightLevelSum = 0;
  for (int i = 1; i &lt; measurementNumber; i++) {
    lightLevelSum += lightMeasurements[i];
  }

  int lightLevelAverage = lightLevelSum / measurementNumber;



  //Update light level measurements
  int currentLightLevel = analogRead(lightLevel);
  lightMeasurements[measurementCount] = currentLightLevel;




  //Change bounds if light level is outside of bounds
  if (lightLevelAverage &lt; lightBottomBound) {
    lightBottomBound = lightLevelAverage;
  }

  if (lightLevelAverage &gt; lightTopBound) {
    lightTopBound = lightLevelAverage;
  }


  //Write to servo
  int servoAngle = map(lightLevelAverage, lightBottomBound, lightTopBound, 0, 180);
  myServo.write(servoAngle);


  delay(1000);

}</pre>
<p>&nbsp;</p>
]]></content:encoded>
					
					<wfw:commentRss>https://courses.ideate.cmu.edu/48-339/s2022/?feed=rss2&#038;p=2300</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		<enclosure url="https://courses.ideate.cmu.edu/48-339/s2022/wp-content/uploads/2022/02/IMG_7377.mp4" length="12592336" type="video/mp4" />

			</item>
		<item>
		<title>Assignment 6:  Data to motion</title>
		<link>https://courses.ideate.cmu.edu/48-339/s2022/?p=2287</link>
					<comments>https://courses.ideate.cmu.edu/48-339/s2022/?p=2287#respond</comments>
		
		<dc:creator><![CDATA[Jet Townsend]]></dc:creator>
		<pubDate>Fri, 18 Feb 2022 02:47:57 +0000</pubDate>
				<category><![CDATA[Assignment 6]]></category>
		<guid isPermaLink="false">https://courses.ideate.cmu.edu/48-339/s2022/?p=2287</guid>

					<description><![CDATA[Use smoothed data as input, output is motion over time.   Making that input accessible via motion is even better. This can be the basis of your Motion Crit as an exploratory experiment Due Monday, 11:59 pm.  If you need help during office hours before class on Tue, drop me email with where you need assistance.]]></description>
										<content:encoded><![CDATA[<p>Use smoothed data as input, output is motion over time.   Making that input accessible via motion is even better.</p>
<p>This can be the basis of your Motion Crit as an exploratory experiment</p>
<p>Due Monday, 11:59 pm.  If you need help during office hours before class on Tue, drop me email with where you need assistance.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://courses.ideate.cmu.edu/48-339/s2022/?feed=rss2&#038;p=2287</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
