Final Project

In this final project I attempted to make an interactive weather station that would be able to get the day’s weather and then give you a suggestion on what to wear based on the weather data that it gets. When I came up with the idea I thought it might be something for younger kids to teach them about the weather and let them know what to wear instead of their parents just telling them what clothes to wear. My original idea was to have an LCD that would put up all minds of weather data like temperature, humidity, wind, etc but I eventually had to scale it down to something more manageable and I figured younger kids would want to just look at a bunch of numbers.

Progress Photos:

I attempted to do this by using the Arduino Uno along with the Sparkfun ESP8266 “Thing” to grab the weather data from the internet, a 16×2 LCD to display the data, and some magnetic switches to choose whether to show the what to wear or the weather. Additionally I added a potentiometer to choose what time of day to show the weather for; morning, afternoon, evening, and nighttime. Ultimately I only got small bit of it to function properly due to some problems I ran into. Firstly I had some trouble getting the WiFi card to send data to the Arduino that could be translated to the LCD as all of the data was being communicated through the Serial monitor which had only one way to send data. Additionally I had to get a new ESP8266 because I accidentally broke the first one while soldering the pins to put it on a protoboard. I also ran into trouble when my magnetic switches stopped recognizing the magnets until they didn’t pick up anything at all therefore the interaction part was not functioning correctly. Finding the hourly weather data was also a problem since almost all the sites that provide weather data require a monthly fee to retrieve that kind of data. For the enclosure I modeled a box in the shape of a cloud using Rhinoceros and then used the laser cutter to cut the layers of the box out of a sheet of plywood. After gluing the pieces of the box together I put the circuit inside. I would like to eventually get this working correctly and maybe even take it further to make an even more sophisticated weather station with real time data.

Circuit:

circuit

 

Final Photos:

This slideshow requires JavaScript.

Video:

Arduino Code:


#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int blueLED = 6;
int redLED = 7;
int greenLED = 8;
int yellowLED = 9;
int potPin = A5;
int sensorValue;
int magnet1 = 10;
int magnet2 = 13;
int weatherProfile;
void setup()
{
lcd.begin (16,2);
Serial.begin(9600);
lcd.setCursor(2,0);
lcd.print("Please Choose");
lcd.setCursor(0,1);
lcd.print("<— or —>");
pinMode(blueLED, OUTPUT);
pinMode(redLED, OUTPUT);
pinMode(greenLED, OUTPUT);
pinMode(yellowLED, OUTPUT);
pinMode(potPin, INPUT);
}
void loop()
{
sensorValue = analogRead(potPin);
Serial.println(sensorValue);
if(sensorValue < 50) {
digitalWrite(redLED, LOW);
digitalWrite(yellowLED, LOW);
digitalWrite(greenLED, LOW);
digitalWrite(blueLED, LOW);
lcd.setCursor(0,0);
lcd.print(" Please Choose");
}
else if(sensorValue >= 50 && sensorValue <= 255) {
digitalWrite(redLED, HIGH);
digitalWrite(yellowLED, LOW);
digitalWrite(greenLED, LOW);
digitalWrite(blueLED, LOW);
lcd.setCursor(0,0);
lcd.print("Good Morning! ");
if(digitalRead(magnet1) == HIGH) {
//getWeather("morning");
}
else if(digitalRead(magnet2) == HIGH) {
//whatToWear(weatherProfile);
}
}
else if(sensorValue >= 256 && sensorValue <= 511) {
digitalWrite(yellowLED, HIGH);
digitalWrite(blueLED, LOW);
digitalWrite(greenLED, LOW);
digitalWrite(redLED, LOW);
lcd.setCursor(0,0);
lcd.print("Good Afternoon! ");
if(digitalRead(magnet1) == HIGH) {
//getWeather("afternoon");
}
else if(digitalRead(magnet2) == HIGH) {
//whatToWear(weatherProfile);
}
}
else if(sensorValue >= 512 && sensorValue <= 767) {
digitalWrite(greenLED, HIGH);
digitalWrite(redLED, LOW);
digitalWrite(blueLED, LOW);
digitalWrite(yellowLED, LOW);
lcd.setCursor(0,0);
lcd.print("Good Evening! ");
if(digitalRead(magnet1) == HIGH) {
//getWeather("evening");
}
else if(digitalRead(magnet2) == HIGH) {
//whatToWear(weatherProfile);
}
}
else if(sensorValue >= 768) {
digitalWrite(blueLED, HIGH);
digitalWrite(yellowLED, LOW);
digitalWrite(greenLED, LOW);
digitalWrite(redLED, LOW);
lcd.setCursor(0,0);
lcd.print("Go to sleep! ");
if(digitalRead(magnet1) == HIGH) {
//getWeather("nighttime");
}
else if(digitalRead(magnet2) == HIGH) {
//whatToWear(weatherProfile);
}
}
}
void getWeather(string timeOfDay) {
int temp;
if(timeOfDay == "morning") {
temp = Serial.read(); //read in temperature from the Serial monitor
if(temp > 80) {
lcd.setCursor(0,0);
lcd.print("It will be hot. ")
}
else if(temp <= 80 && temp > 45) {
lcd.setCursor(0,0);
lcd.print("It will be mild. ")
}
else if(temp <= 45 && temp > 40) {
lcd.setCursor(0,0);
lcd.print("It will be cold. ")
}
else {
lcd.setCursor(0,0);
lcd.print("It will be frigid. ")
}
}
else if(timeOfDay == "afternoon") {
temp = Serial.read();
if(temp > 80) {
lcd.setCursor(0,0);
lcd.print("It will be hot. ")
}
else if(temp <= 80 && temp > 45) {
lcd.setCursor(0,0);
lcd.print("It will be mild. ")
}
else if(temp <= 45 && temp > 40) {
lcd.setCursor(0,0);
lcd.print("It will be cold. ")
}
else {
lcd.setCursor(0,0);
lcd.print("It will be frigid. ")
}
}
else if(timeOfDay == "evening") {
temp = Serial.read();
if(temp > 80) {
lcd.setCursor(0,0);
lcd.print("It will be hot. ")
}
else if(temp <= 80 && temp > 45) {
lcd.setCursor(0,0);
lcd.print("It will be mild. ")
}
else if(temp <= 45 && temp > 40) {
lcd.setCursor(0,0);
lcd.print("It will be cold. ")
}
else {
lcd.setCursor(0,0);
lcd.print("It will be frigid. ")
}
}
else if(timeOfDay == "nighttime") {
temp = Serial.read();
if(temp > 80) {
lcd.setCursor(0,0);
lcd.print("It will be hot. ")
}
else if(temp <= 80 && temp > 45) {
lcd.setCursor(0,0);
lcd.print("It will be mild. ")
}
else if(temp <= 45 && temp > 40) {
lcd.setCursor(0,0);
lcd.print("It will be cold. ")
}
else {
lcd.setCursor(0,0);
lcd.print("It will be frigid. ")
}
}
}
void whatToWear(int weatherProfile) {
if(weatherProfile == 1) {
lcd.setCursor(0,1);
lcd.print("T-shirt+Shorts ");
}
else if(weatherProfile == 2) {
lcd.setCursor(0,1);
lcd.print("T-shirt+Pants ");
}
else if(weatherProfile == 3) {
lcd.setCursor(0,1);
lcd.print("Jacket+Pants ");
}
else {
lcd.setCursor(0,1);
lcd.print("Wintercoat+Pants ");
}
}

ESP8266 Code:


#include <ESP8266WiFi.h>
#ifndef min
#define min(x,y) (((x)<(y))?(x):(y))
#endif
#ifndef max
#define max(x,y) (((x)>(y))?(x):(y))
#endif
#include <ArduinoJson.h>
const char SSID[] = "******"; //Wifi name
const char PASSWORD[] = "*********"; //Wifi password
// Use your own API key by signing up for a free developer account.
// http://www.wunderground.com/weather/api/
#define WU_API_KEY "faa6a04ec4a845f2b7ce096c9a80ace5"
// Specify your favorite location one of these ways.
//#define WU_LOCATION "CO/BOULDER"
// US ZIP code
//#define WU_LOCATION ""
#define WU_LOCATION "80303"
// Country and city
//#define WU_LOCATION "United States/Boulder"
// 5 minutes between update checks. The free developer account has a limit
// on the number of calls so don't go wild.
#define DELAY_NORMAL (5*60*1000)
// 20 minute delay between updates after an error
#define DELAY_ERROR (20*60*1000)
#define WUNDERGROUND "api.wunderground.com"
// HTTP request
const char WUNDERGROUND_REQ[] =
"GET /api/" WU_API_KEY "/conditions/q/" WU_LOCATION ".json HTTP/1.1\r\n"
"User-Agent: ESP8266/0.1\r\n"
"Accept: */*\r\n"
"Host: " WUNDERGROUND "\r\n"
"Connection: close\r\n"
"\r\n";
void setup()
{
Serial.begin(115200);
// We start by connecting to a WiFi network
Serial.println();
Serial.println();
Serial.print(F("Connecting to "));
Serial.println(SSID);
WiFi.begin(SSID, PASSWORD);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(F("."));
}
Serial.println();
Serial.println(F("WiFi connected"));
Serial.println(F("IP address: "));
Serial.println(WiFi.localIP());
}
static char respBuf[4096];
void loop()
{
// TODO check for disconnect from AP
// Open socket to WU server port 80
Serial.print(F("Connecting to "));
Serial.println(WUNDERGROUND);
// Use WiFiClient class to create TCP connections
WiFiClient httpclient;
const int httpPort = 80;
if (!httpclient.connect(WUNDERGROUND, httpPort)) {
Serial.println(F("connection failed"));
delay(DELAY_ERROR);
return;
}
// This will send the http request to the server
Serial.print(WUNDERGROUND_REQ);
httpclient.print(WUNDERGROUND_REQ);
httpclient.flush();
// Collect http response headers and content from Weather Underground
// HTTP headers are discarded.
// The content is formatted in JSON and is left in respBuf.
int respLen = 0;
bool skip_headers = true;
while (httpclient.connected() || httpclient.available()) {
if (skip_headers) {
String aLine = httpclient.readStringUntil('\n');
//Serial.println(aLine);
// Blank line denotes end of headers
if (aLine.length() <= 1) {
skip_headers = false;
}
}
else {
int bytesIn;
bytesIn = httpclient.read((uint8_t *)&respBuf[respLen], sizeof(respBuf) – respLen);
Serial.print(F("bytesIn ")); Serial.println(bytesIn);
if (bytesIn > 0) {
respLen += bytesIn;
if (respLen > sizeof(respBuf)) respLen = sizeof(respBuf);
}
else if (bytesIn < 0) {
Serial.print(F("read error "));
Serial.println(bytesIn);
}
}
delay(1);
}
httpclient.stop();
if (respLen >= sizeof(respBuf)) {
Serial.print(F("respBuf overflow "));
Serial.println(respLen);
delay(DELAY_ERROR);
return;
}
// Terminate the C string
respBuf[respLen++] = '\0';
Serial.print(F("respLen "));
Serial.println(respLen);
//Serial.println(respBuf);
if (showWeather(respBuf)) {
delay(DELAY_NORMAL);
}
else {
delay(DELAY_ERROR);
}
}
bool showWeather(char *json)
{
StaticJsonBuffer<3*1024> jsonBuffer;
// Skip characters until first '{' found
// Ignore chunked length, if present
char *jsonstart = strchr(json, '{');
//Serial.print(F("jsonstart ")); Serial.println(jsonstart);
if (jsonstart == NULL) {
Serial.println(F("JSON data missing"));
return false;
}
json = jsonstart;
// Parse JSON
JsonObject& root = jsonBuffer.parseObject(json);
if (!root.success()) {
Serial.println(F("jsonBuffer.parseObject() failed"));
return false;
}
// Extract weather info from parsed JSON
JsonObject& current = root["current_observation"];
const float temp_f = current["temp_f"];
Serial.print(temp_f, 1); Serial.print(F(" F, "));
const float temp_c = current["temp_c"];
const char *humi = current[F("relative_humidity")];
const char *weather = current["weather"];
const char *pressure_mb = current["pressure_mb"];
const char *observation_time = current["observation_time_rfc822"];
// Extract local timezone fields
const char *local_tz_short = current["local_tz_short"];
const char *local_tz_long = current["local_tz_long"];
const char *local_tz_offset = current["local_tz_offset"];
return true;
}

ESP8266 Code reference: https://gist.github.com/bbx10/149bba466b1e2cd887bf

 

Lab 8: Serial Processing

In this lab I used and Arduino and Serial processing to create a simple interface. To do this I had to use Arduino programming along with a program written using Processing to allow the Arduino to communicate with the computer screen. I used a cicuit with two potentiometers and an LED to provide input and output from the board. Once the Processing program is run A white background with a colored box appears on the screen the potentiometers change the x an y coordinates of the box on the. The box begins as red but will alternate between 3 colors; red, green , and blue. The box will change color when the screen is clicked and when the box turns green the LED is turned on.

Arduino Code:


int sensor1;
int sensor2;
char val;
int ledPin = 11;
void setup() {
Serial.begin(9600);
//send something to start out
//when we start, send something to processing
Serial.println("0");
pinMode(ledPin, OUTPUT);
}
void loop() {
//send data only when it is requested
if (Serial.available() > 0) {
//read for LED
val = Serial.read();
//read incoming from processing
char input = Serial.read();
//then send our data
sensor1 = analogRead(A0);
sensor2 = analogRead(A1);
Serial.print(sensor1);
Serial.print(",");
Serial.println(sensor2);
}
//LED STUFF
//interpret incoming values (will be from processing)
if (val == '1') {
digitalWrite(ledPin, HIGH);
}
if (val == '0') {
digitalWrite(ledPin, LOW);
}
}

Processing Code:


import processing.serial.*;
//instance of the serial library
Serial myPort;
color red = color(255, 0, 0);
color green = color(0, 255, 0);
color blue = color(0, 0, 255);
float sensor1;
float sensor2;
float ballx;
float bally;
int counter = 1;
void setup() {
size(600, 400);
println(Serial.list());
String portName = "COM3";
myPort = new Serial(this, portName, 9600);
myPort.bufferUntil('\n');
}
void draw() {
background(255);
noStroke();
smooth();
ballx = map(sensor1, 0, 1023, 15, width-15);
bally = map(sensor2, 0, 909, 15, height-15);
rect(ballx, bally, 80, 80, 10);
//fill(red);
if(counter == 1) {
fill(red);
}
else if(counter == 2) {
fill(green);
}
else if(counter == 3) {
fill(blue);
}
}
void mouseClicked() {
String s = "Eureka!";
textSize(32);
text(s, 10, 30);
textAlign(CENTER);
counter++;
if(counter == 4) {
counter = 1;
}
if(counter == 2) {
println("led on");
myPort.write("1");
}
else {
println("led off");
myPort.write("0");
delay(10);
}
println(counter);
rotate(PI/3.0);
}
void serialEvent(Serial myPort) {
String input = myPort.readStringUntil('\n');
if (input != null) {
input = trim(input);
int[] sensors = int(split(input, ','));
if (sensors.length>1) {
sensor1 = sensors[0];
sensor2 = sensors[1];
}
}
myPort.write('x');
}

Working Circuit:

Project 2 Proposal

For this project I plan to make a desk organizer that can open and close the drawers using gestures. The organizer will have 2-3 compartments that can be opened and closed using a gesture sensor to track the movement of the user, for example; the user moves their hand in an upwards motion and the first compartment or drawer is opened, then when the user moves their hand in a downward motion the open compartment or drawer will be closed. This can be repeated to open other compartments using a rightward or leftward hand movement to open 2nd or 3rd compartments. This is an interesting project because people interact with so many kinds of objects in the world today. Interaction is a very important part of our lives since we interact with so many things in so many different ways every day.


Timeline:

April 6-11- Design enclosure and order parts

April 11-19- Construct prototype and begin to build circuit/write code

April 20- Present 1st prototype in class

April 21-28- Construct final version of enclosure and continue working  on circuit to get it working properly

April 29-May 3- Finalize project and get everything working correctly

May 4- Present final project in class

Parts list:

1x Arduino Uno

1x  ZX Distance and Gesture Sensor

1x Stepper motor driver

2-3x Stepper motors

Lab 7: Motors

Part 1: DC Motor

This circuit uses switch to control a DC motor using the Arduino. I had to use an H-bridge to help connect and control the DC motor. I placed the H-bridge on the breadboard and then connected it to the Arduino and DC motor using the schematic from the lab write-up.

DC

Next I hooked up the Arduino to the computer and wrote some code that would make the motor spin clockwise or counterclockwise based on the state of the switch. Once I had that working I changed the code so it would spin on one switch state and stop spinning on the other switch state.


const int switchPin = 2;
const int motor1Pin = 3;
const int motor2Pin = 4;
const int enablePin = 9;
void setup() {
pinMode(switchPin, INPUT);
pinMode(motor1Pin, OUTPUT);
pinMode(motor2Pin, OUTPUT);
pinMode(enablePin, OUTPUT);
analogWrite(enablePin, 100);
}
void loop() {
int switchVal = digitalRead(switchPin);
if(switchVal == HIGH) {
digitalWrite(motor1Pin, HIGH);
digitalWrite(motor2Pin, LOW);
}
else {
digitalWrite(motor1Pin, LOW);
digitalWrite(motor2Pin, LOW);
}
}

view raw

DC-motor.ino

hosted with ❤ by GitHub

Part 2: Stepper Motor

For this circuit I used the H-bridge again this time to run a stepper motor to make it turn in “steps”. Using the schematic on the lab write-up for reference I connected the stepper motor to the H-bridge and then the H-bridge to the Arduino before connecting it to the computer to upload the code.

stepper.jpg

I then used the stepper revolution code example from the lab to help write the code to make the stepper motor move one step clockwise and then one step counterclockwise.


#include <Stepper.h>
const int stepsPerRev = 200;
Stepper myStepper(stepsPerRev, 8, 9, 10, 11);
void setup() {
myStepper.setSpeed(60);
Serial.begin(9600);
}
void loop() {
Serial.println("clockwise");
myStepper.step(stepsPerRev);
delay(500);
Serial.println("counterclockwise");
myStepper.step(-stepsPerRev);
delay(500);
}

view raw

stepper.ino

hosted with ❤ by GitHub

 

Project 1 :Artificial Human Companion- Baxter the Security Pig (Jess and Alejandro)

Project 1 tasked us with creating an object that would act as some sort of artificial companion that is able to interact with a person and acts as some sort of companion so we began by brainstorming some ideas. We thought a good companion would be some kind of artificial pet so we wanted to do some kind of toy animal an eventually settled on a piggy bank. We figured that if a piggy bank is used for saving your money that it should have some security measures just to keep it extra safe so we decided to add an alarm system along with some LEDs for visual feedback. We also decided to a motion sensor to sense when coins were put into the piggy bank. We initially planned to also add some light sensitive resistors to make it act as a night light but later scrapped the idea and chose to focus on the alarm and the motion sensor.

brainstorm

Next we went to Sparkfun’s website to look up parts and ended up buying the parts below:

1x LIS3DH Triple Axis Accelerometer (SEN-13963)
1x PIR Motion Sensor (SEN-13285)
1x MP3 Player Shield (DEV-12660)
1x Toggle Switch (COM-09276)

We also used parts we already owned listed below:

2x Arduino Uno
3x 220 ohm resistors
1x 10K ohm resistor
4x RGB LEDs
2x 9V batteries
1x 8GB microSD card

And for the enclosure we bought an 11″ plastic piggy bank from Amazon along with some buckle latches and a hinge from Home Depot:
https://www.amazon.com/Giant-Plastic-Piggy-Saving-Colors/dp/B00DMEC810
https://www.amazon.com/gp/product/B01MR126O6/ref=oh_aui_detailpage_o00_s00?ie=UTF8&psc=1

Once we had all of our parts we put the LEDs (wired in parallel) and motion sensor on one arduino and then the accelerometer, MP3 shield, and speaker on the other arduino to split up the work. Though we initially planned to put all of the components onto a single arduino when tried to do it none of our components were working properly or getting enough power so we decide just to keep both arduinos and connect them together.

schematic

This slideshow requires JavaScript.

After hooking up our parts and then moving them to a protoboard we looked up some tutorials and hookup guides to help us write the code we needed for our idea to work. The most difficualt part was probably getting the MP3 shield to work properly with the arduino and accelerometer since there are a limited amount of pins that the MP3 shield doesn’t use. The code for the shield was more complex than we though it would be and there were very few good tutorials so it was harder to change the code to make it do what we wanted. Once it was working we coded the MP3 shield to constantly read coordinates from the accelerometer and trigger an alarm sound if the coordinates changed more than a certain amount so if you tilt it or turn it over to get the money out the alarm will sound. The RGB LEDs and the motion sensor we coded to talk to each other so that the lights would flash green when the sensor detects a coin entering the piggy bank. This would also send a signal to the other arduino to tell it to play a coin sound.

LEDs and Motion Sensor code:


int pirPin = 10;
int redLED = A4;
int greenLED = A2;
int blueLED = A3;
int coinSound= 7;
void setup() {
Serial.begin(9600);
pinMode(pirPin, INPUT);
pinMode(redLED, OUTPUT);
pinMode(greenLED, OUTPUT);
pinMode(blueLED, OUTPUT);
pinMode(coinSound, OUTPUT);
}
void loop() {
int pirVal = digitalRead(pirPin);
if(pirVal == LOW) {
Serial.println("Motion Detected");
//delay(1500);
analogWrite(blueLED, 0);
analogWrite(greenLED, 1023);
delay(1500);
digitalWrite(coinSound, HIGH);
}
else {
Serial.println("None");
analogWrite(greenLED, 0);
analogWrite(blueLED, 1023);
//analogWrite(blueLED, 0);
digitalWrite(coinSound,LOW);
}
}

Accelerometer and MP3 Shield code:


#include "SparkFunLIS3DH.h"
#include "Wire.h"
#include "SPI.h"
#include <SdFat.h> // SDFat Library
#include <SdFatUtil.h> // SDFat Util Library
#include <SFEMP3Shield.h> // Mp3 Shield Library
LIS3DH myIMU; //Default constructor is I2C, addr 0x19.
int val=0;
int pinCheck= 5;
uint8_t result;
float xcord=0;
float ycord=0;
float zcord=0;
SdFat sd;
SFEMP3Shield MP3player;
const uint8_t volume = 0; // MP3 Player volume 0=max, 255=lowest (off)
const uint16_t monoMode = 1; // Mono setting 0=off, 3=max
bool playSound= false;
char trackName[] = "track001.mp3";
char trackTwo[] = "track002.mp3";
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
delay(1000); //relax…
Serial.println("Processor came out of reset.\n");
pinMode(pinCheck, INPUT);
//Call .begin() to configure the IMU
myIMU.begin();
/* Set up all trigger pins as inputs, with pull-ups activated: */
initSD(); // Initialize the SD card
initMP3Player(); // Initialize the MP3 Shield
}
void loop()
{
val= digitalRead(pinCheck);
xcord= myIMU.readFloatAccelX();
ycord= myIMU.readFloatAccelY();
zcord= myIMU.readFloatAccelZ();
if(val ==HIGH){
Serial.println("Coin Sound is playing");
result = MP3player.playMP3(trackTwo);
delay(1000);
}
if(val ==LOW){
Serial.println("Coin Sound dead");
MP3player.stopTrack();
}
if(xcord > -.5 || xcord < -1.2){
playSound= true;
Serial.println("Xcordinate");
}
else if(ycord > .2 || ycord < -.4){
playSound= true;
Serial.println("Ycordinate");
}
else if(zcord > .6 || zcord < -.1){
playSound= true;
Serial.println("Zcordinate");
}
else{
playSound=false;
MP3player.stopTrack();
Serial.println("Play sound is false");
}
if(playSound == true){
Serial.println("Play sound is true");
Serial.println("About to play track");
result = MP3player.playMP3(trackName);
}
//Get all parameters
Serial.print("\nAccelerometer:\n");
Serial.print(" X = ");
Serial.println(xcord, 4);
Serial.print(" Y = ");
Serial.println(ycord, 4);
Serial.print(" Z = ");
Serial.println(zcord, 4);
delay(1000);
}
void initSD()
{
//Initialize the SdCard.
if(!sd.begin(SD_SEL, SPI_HALF_SPEED))
sd.initErrorHalt();
if(!sd.chdir("/"))
sd.errorHalt("sd.chdir");
}
void initMP3Player()
{
uint8_t result = MP3player.begin(); // init the mp3 player shield
if(result != 0) // check result, see readme for error codes.
{
// Error checking can go here!
}
MP3player.setVolume(volume, volume);
MP3player.setMonoMode(monoMode);
}

view raw

alarm-code.ino

hosted with ❤ by GitHub

After we got the code working we cut open our piggy bank and stuck the arduinos and the batteries on the bottom, poking some holes in the nose and eyes to hold the lights. The motion sensor was stuck to the top of the pig inside the coin collection area. We then put a divider made of cardboard inside the pig to keep the coin collecting section separate from the electronics and added a hinge on one side and a latch on the other to keep it closed.

This slideshow requires JavaScript.

Once finished our product worked correctly for the most part but our motion sensor was a little too sensitive and our piggy bank was a little too small and to thin to keep the motion sensor from detecting outside motion but overall we were fairly pleased with how it turned out.

This slideshow requires JavaScript.

Reference materials:
Accelerometer-
https://learn.sparkfun.com/tutorials/lis3dh-hookup-guide?_ga=1.112035716.1224567344.1488051038
https://github.com/sparkfun/SparkFun_LIS3DH_Arduino_Library

Motion Sensor-
http://bildr.org/2011/06/pir_arduino/

MP3 Shield:
https://learn.sparkfun.com/tutorials/mp3-player-shield-hookup-guide-v15?_ga=1.14674871.1224567344.1488051038

Lab 6

The servo motor circuit was a servo motor and a variable resistor hooked up to the Arduino. I used the dial variable resistor connecting it to an analog pin to read in the value. I then connected the servo motor into a digital pin and after putting in the code used the dial to turn the servo motor back and forth. 

I made the speaker circuit using a small speaker and a couple of photoresistors connected to the Arduino. I had to solder some wires to the speaker to connect it to the breadboard and then connected it to one of the digital pins. I then connected the photoresistors to power and added a wire from an analog pin to the point between the photoresistors. After loading the code to the Arduino the pitch of the speaker would change when covering or exposing the the resistors to light. 


For my enclosure I made a “jazz hands” box using the servo motor and some photoresistors. When the box is exposed to light the hands wave back and forth and when it’s in a dark place or the resistors are covered up the hands stop waving.

Lab 5

So this circuit uses an Arduino unit, 2 variable resistors and 2 LEDs of different colors that will get dimmer and brighter based on the state of the variable resistor.

Each LED has its own separate potentiometer so the brightness level of each light can be controlled separately. I started by just making a circuit with one LED to get it working (Seen in video below).

Once I had that working I did some wire rearranging and added a second LED on its own circuit, this time with a slider potentiometer which I soldered some wires to to connect it to the breadboard.

I had some trouble getting the LEDs to dim and brighten correctly and they wouldn’t turn all the way off. I found that when I removed the 10K ohm resistors between the variable resistors and ground and just used a wire to connect the potentiometers to ground the LEDs would turn all the way off. 

Here is a video of the finished circuit.

Lab 4

Here I made a small circuit with a switch and two LEDs using the Arduino Uno microcontroller. After connecting each component in series with a resistor to the breadboard I connected each of them to their appropriate pins on the Arduino board. I then wrote some code to tell the Arduino what to do on start-up and when the button is pushed.

code

Lab 3

So I started with just a simple circuit with one LED to see If I could get it to work so then I decided to make a parallel circuit with two LEDs. I didn’t really struggle with anything in this lab mostly because I’ve soldered quite a bit before this and I actually kind of like it anyways.

 

For my interactive object I chose and electric longboard with an LCD that gives some info to the rider. It would be near the front of the board and would display things like the current speed, the battery level of the longboard, and/or the date and time. I decided to do this because I think it would be cool to know how fast your longboard is going especially if it’s an electric powered longboard. It would also be useful to see the date and time in case you want to check the time but you don’t have a watch and you don’t want to pull out your phone. It’s also useful to know where the batter level is so it doesn’t die while your riding it.

longboardlongboard-sketch

Lab 2 Post

The difference between a circuit in series and a circuit in parallel is the way in which the electricity travels. In a series circuit the components all run along one path where the current stays the same and the voltage is split between the components. In a parallel circuit the components have multiple paths where the current is split between the paths and the voltage remains the same across the components.

When connecting several LEDs it would be better to use a parallel circuit because the voltage across each light would be the same and the LEDs would be equally bright.