Lab 4
This lab introduced the concept of serial processing in real time. It also built upon the idea of potentiometers by introducing new potentiometers such as the Force Sensitive Resistor (FSR) and a photoresistor.
First the circuit was built as shown in the provided circuit diagram. This utilized the photoresistor to light a LED. The same circuit was then used with a FSR to demonstrate the capabilities of both.
The third part of the lab involved downloading the program called Processing. The Processing provides unique capabilities to create graphical images on the screen of the computer using serial inputs sent to it via the keyboard, mouse, or serial port.
Programming HW
By programming the Arduino to print values to the serial port, the Processing code created visual images based on these values. Specifically, when the FSR is pressed the screen will shift from Green to Red based on the value sent to the processing code. In addition, using the value sent to the Processing code the size of a string of text that is centered in the middle of the screen will grow or shrink. Also when the serial value is above a midway point the text content will change.
Mechanical HW
For the mechanical construction utilizing a FSR, I created a plate to leave the users day to day objects that are carried with them. Focusing on a wallet, this plate focuses the normal force at one of 3 legs with the FSR under the one leg. The idea from this is that you would be able to determine the amount of money in your wallet from the visual. In addition for future development different weight classes could be used to determine if you are missing anything as you are walking out the door, such as your keys, sunglasses, chap stick, etc.
Materials:
1 – Arduino Uno
1 – Laptop
1 – 1K ohm resistor
1 – Breadboard
1 – FSR
1 – Wallet
1 – Plastic top
1- USB Cable
Arduino Code
/* Kevin Lessard
Lab 4 Serial read for processing program
*/
int analog0 = 0;
void setup(){
Serial.begin(9600);
}
void loop(){
analog0 = map(analogRead(A0),190,520,50,255); //maping values from analog FSR (0 to 1023) to what is being acted on in the Processing Code
Serial.println(analog0);
delay(10);
}
Processing code
/*
Kevin Lessard
TUI Lab 4 Code
Influenced heavily by code provided by JeremyBlum from Tutorial 6 for Arduino
*/
import processing.serial.*;
Serial port;
float var2 = 50;
void setup() {
size(1400,800);
port = new Serial(this, "COM4", 9600);
port.bufferUntil('\n');
}
void draw()
{
if(var2<127){
background(0,var2+135,0);
fill(0);
textSize(var2/2);
textAlign(CENTER);
text("No Money, No Problems", 700, 400);
}
if(var2>127){
background(var2+100,0,0);
fill(0);
textSize(var2/2);
textAlign(CENTER);
text("Mo Money, Mo Problems", 700, 400);
}
}
void serialEvent (Serial port)
{
var2 = float(port.readStringUntil('\n'));
}
- Login to post comments