-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.xml
113 lines (87 loc) · 5.34 KB
/
index.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>Seth's Blog</title>
<link>http://www.sbporter.com/index.xml</link>
<description>Recent content on Seth's Blog</description>
<generator>Hugo -- gohugo.io</generator>
<language>en-us</language>
<copyright>Powered by [Hugo](http://gohugo.io).</copyright>
<lastBuildDate>Tue, 13 Dec 2016 10:53:59 -0600</lastBuildDate>
<atom:link href="http://www.sbporter.com/index.xml" rel="self" type="application/rss+xml" />
<item>
<title>First Arduino Project</title>
<link>http://www.sbporter.com/post/scanner/</link>
<pubDate>Tue, 13 Dec 2016 10:53:59 -0600</pubDate>
<guid>http://www.sbporter.com/post/scanner/</guid>
<description><p>Recently I have been looking at Arduinos, and all the exciting possibilities surrounding the platform. One of the things that particularly intrigued me were Internet of Things (IOT) applications such as remote monitoring for things like temperature, humidity, ambient light, air quality, etc. I was also interesting in doing some things with LED RGB light strips, animations, and sound reactive lighthing. One of the videos I found particularly intruging, can be found here: <a href="https://www.youtube.com/watch?v=VqIki2_3foM">Youtube: Sound reactive led strip 2.0</a></p>
<p>After doing some research, I ordered two Wemos D1 Mini Pros from aliexpress for $5 each. These chips are based on the ESP8266 chipset, bringing WiFi capabilities to the Arduino. I also ordered some SHT30 Temperature and Humididty sensors. I&rsquo;ll write a post about these later on, after they arrive. In the meantime, I got sick of waiting for them to arrive from China, so I bought an Arduino Uno from Radioshack. It was a bit overpriced, but I figured it was worth it to be able to begin tinkering sooner.</p>
<p>I didn&rsquo;t have much in the way of parts on hand. I took a basic electronics class in college, and was able to scrounge up some leftover parts from that. I found 5 LEDs, a potentiometer, a breadboard, a few resistors, and some wires. Not a whole lot to work with. I set out to build the coolest thing I could think of. I wanted to familarize myself with Arduino, the IDE, and refresh my knowledge of basic electronics.</p>
<p>The idea was to build a line of 5 LEDs, and have them scan back and forth. I also had a potentiometer, and thought it would be cool to be able to change the speed of the scanning by adjusting the potentiometer.</p>
<p><img src="http://www.sbporter.com/img/scanner.jpg" alt="Arduino LED Scanner" /></p>
<p>The positive LEDs are connected to pins 2 through 6 on the Arduino Uno board, and the negative ends are connected to ground via a 270Ω resistor. The potentiometer is connected to analog pin 0 on the Arduino. I actually have no idea how many homes it is. Seems to work fine though. If you turn the dial clockwise, the scanning slows down. If you turn it counter-clockwise, it speeds up. In code, I set it to be variable from 30 to 200 ms in between light changes.</p>
<p>Here is a video of it in action:
<div style="position: relative; padding-bottom: 56.25%; padding-top: 30px; height: 0; overflow: hidden;">
<iframe src="//www.youtube.com/embed/fAfd-U23jsE" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;" allowfullscreen frameborder="0"></iframe>
</div>
</p>
<p>Source Code:</p>
<pre>
<code class="c++">
/*
LED Scanner
Turns the LEDs on one by one, sweeping back and forth in a scanning pattern
This code was written for and tested on the Arduino Uno
This example code is in the public domain.
December 10, 2016
Seth Porter
*/
// Analog pin used to read from the potentiometer
const int analogPin = A0;
// The pins used as LED outputs
int ledPins[] = {
2, 3, 4, 5, 6
};
// Total number of LEDs
const int ledCount = 5;
// Initial value (delay in ms)
int delayValue = 50;
void setup() {
// Loop through the LEDs, and set them up as digital output pins
for (int thisLed = 0; thisLed < ledCount; thisLed++) {
pinMode(ledPins[thisLed], OUTPUT);
}
}
void loop() {
// Loop through LEDs in ascending order, turning them on one by one
for (int thisLed = 0; thisLed < ledCount; thisLed++) {
resetLights();
digitalWrite(ledPins[thisLed], HIGH);
delayValue = speedForAnalogSensor(analogPin);
delay(delayValue);
}
// Descend through LEDs, skipping the last and the first pin as they are already covered in the first loop.
for (int thisLed = ledCount-2; thisLed > 1; thisLed--) {
resetLights();
digitalWrite(ledPins[thisLed], HIGH);
delayValue = speedForAnalogSensor(analogPin);
delay(delayValue);
}
}
// Helper function which turns off all the lights
void resetLights() {
for (int thisLed = 0; thisLed < ledCount; thisLed++) {
digitalWrite(ledPins[thisLed], LOW);
}
}
// Reads an analog pin, and returns a mapped value between 30 and 200.
int speedForAnalogSensor(int pin) {
int sensorReading = analogRead(pin);
return map(sensorReading, 0, 1023, 30, 200);
}
</code>
</pre>
</description>
</item>
</channel>
</rss>