Wendy Lin's project 1 board
A mechanism that takes the potentiometer value to move motor, moving the crank slider. Ultrasonic ranger measures slider distance and arduino maps that to the incandescent light bulb brightness.
Luke Shen's project 1 board, consisting of an Arduino Uno in the top left corner, a breadboard with color-coded wires and a potentiometer connecting to things across the board, a lego crank-slider mechanism controlled by a servo, whos movement is being measured by an ultrasonic ranger, an incandescent light bulb set to become brighter or dimmer depending on the crank slider's distance, and an lcd display that shows the variables controlling all the moving parts
Wendy's ultrasonic sensor used to as the middle transducer to measure crank slider distance.
Wendy's lcd display taht shows variables recieved by the sensors.
Wendy's servo motor. Servo motor rotates depending on Arduino signal from mapped potentiometer value.
Wendy's incandescent light bulb, which produces light and heat as an output. Brightness is shown according to Arduino signal that is mapped from ultrasonic ranger.
A video showing Wendy Lin's board transduce from rotation to distance to temperature through the different sensors
A video showing Luke Shen's board transduce from rotation to distance to temperature through the different sensors
A small metal knob is twisted to move a popsicle stick wall forward. When the popsicle stick wall moves forward, a distance sensor (the sensor that looks like goggles), measures the distance between it and the wall. This measurement is sent to the lightbulb, where it changes how bright it is depending on the measurement.
Luke: Final 3 ideas drawn out on the whiteboard table, we most likely will go for idea 1
Luke: Check in with Zach, where we explain our ideas and sketch out on our whiteboard table how we might implement this
Wendy: Checking the wiring of the lcd display to make everything works before gluing it down.
Wendy: Progress pictures of all the wires to make sure everything is connected
Ultimately, the thing that was most difficult about the process was working out what went wrong. In theory and concept, everything makes sense until hardware is applied. Then finding good debugging methods is difficult.
For example, getting the initial concept drawings and the supposed application of our sensors was pretty easy. Especially since we chose to use parts that we had worked with before in the tutorials. However, once the actual application started, such as combining the units of working code, as well as bouncing between understanding if the code or hardware didn't work, that was where the majority of the time was spent. Since neither of us was very familiar with Arduino code, both of us had to really switch back and forth between checking the code versus checking the wiring. In Wendy's case, she spent a lot of time assembling the wiring and understanding how to get all the circuitry to work. Luke ended up using Wendy's design to complete the project, and still found difficulty in putting the completed design together, despite having working hardware to reference. For example, Luke spent an hour trying to understand why the skip button did not work, by editing the circuits and checking grounds, only to realize the button itself did not work.
In retrospect, we were both glad that we had a project that was based on the tutorials of the work we did, and wouldn't really change too much. However, through this project, we really gained an understanding of the time required to get simple ideas to work well, and how the development and debugging of projects is very time-consuming.
//Double Transducer Project 1:
//Wendy Lin and Luke Shen
//The code takes in a potentiometer value and sends it to the motor
//it also takes the value of the ultrasonic sensor and sends it to the
//bulb. If the trigger is pushed, it sends the poteniometer value to the
//bulb instead.
/*
Pin mapping:
Arduino pin | role | description
-------------------------------------
A0 input Potentiometer
2 output Servo Motor
8 input Button skip-the-middle
6 output Bulb
12 Ultrasonic Ranger Trigger
11 Ultrasonic Ranger Echo
*/
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <NewPing.h>
#include <Servo.h>
#define ECHO_PIN 11
#define MAX_DISTANCE 200
//Setting the Pin numbers
const int POTPIN = A0;
const int GAUGEMOTORPIN = 2;
const int BUTTONPIN = 8;
const int BULBPIN = 6;
const int TRIGGER_PIN = 12;
//Motor
Servo gaugeMotor;
NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE);
//LCD Screen
LiquidCrystal_I2C screen(0x27, 16, 2);
///////////////
void setup() {
//Reading Pins
pinMode(POTPIN, INPUT);
pinMode(GAUGEMOTORPIN, OUTPUT);
pinMode(BUTTONPIN, OUTPUT);
pinMode(BULBPIN, OUTPUT);
//Gauge Motor read
gaugeMotor.attach(GAUGEMOTORPIN);
Serial.begin(9600);
gaugeMotor.write(0);
delay(1000);
//Screen
screen.init();
screen.backlight();
screen.home();
screen.print("Hello, world!");
screen.setCursor(0, 1);
}
void loop() {
// bulb brightness
int brightness = 0;
//readimg values
int potVal = analogRead(POTPIN);
int buttonVal = digitalRead(BUTTONPIN);
//potentiometer read and map to motor
int potDispVal = map(potVal, 0, 1023, 0, 99);
int motorVal = map(potVal, 0, 1023, 0, 47);
int motorDispVal = map(motorVal, 0, 47, 0, 99);
//reading distance and map to display
int distance = (sonar.ping_cm());
int distDispVal = map(distance, 2, 9, 0, 99);
if (buttonVal == HIGH) {
//if button pressed, map potentiometer to brightness
Serial.println(5);
brightness = map(potVal, 0, 1023, 0, 255);
analogWrite(BULBPIN, brightness);
delay(10);
} else {
//if button not pressed, move motor and use distance from ultrasonic ranger
gaugeMotor.write(motorVal);
delay(10);
// mapping distance to brightness
Serial.println(0);
brightness = map(distance, 2, 9, 0, 255);
analogWrite(BULBPIN, brightness);
delay(10);
}
//display brightness
int brightDisp = map(brightness, 0, 255, 0, 99);
// LCD Display
screen.clear();
screen.print("i:");
screen.print(potDispVal);
screen.print(" ");
screen.print("m:");
screen.print(motorDispVal);
screen.setCursor(7, 1);
screen.print(distDispVal);
screen.setCursor(11, 1);
screen.print("o:");
screen.print(brightDisp);
screen.setCursor(0, 1);
}