Bubbly Circles and Door Bell Chimes

Assignment: Sensing PART II: Force Sensitive Resistors and Photocells

Collaborators:

Part 1: Programming

I have created the circle/bubble art in this example. Random circles/bubbles are generated on the screen when arduino is connected. Following is the code for the same.

import processing.serial.*;

boolean button = false;

int x;
int y;
int r;
String portname = "COM3"; // or "COM5"

Serial port;
String buf="";
int cr = 13;  // ASCII return   == 13
int lf = 10;  // ASCII linefeed == 10

void setup()
{
size(700,700);
port = new Serial(this, portname, 9600);
frameRate(10);
}
void draw(){}

void drawBall(int val)
{
// The FSR is touched then val will have the force value.
if (val > 0)
{
button = true;
r = val;
}
else
{
button = false;
r = 100;
}

if (button)
{
background(255);
stroke(0);
}
else
{
background(0);
stroke(255);
}

fill(175);
ellipse(x,y,r,r);
}

// called whenever serial data arrives
void serialEvent(Serial p)
{
int c = port.read();
if (c != lf && c != cr)
{
buf += char(c);
}
if (c == lf)
{
int val = int(buf);
println("val="+val);
x = int(random(0,width));
y = int(random(0,height));   
drawBall(val);
buf="";
}

}

Part 2: Door Bell stimulator

Description: Door bell sound is indicator of someone standing at your door. But it is not the case for the people who have hearing impairments. So to address this problem I have created door bell stimulator. FSR is wrapped in package beans to sense door bell press action. I used package beans since it highly resembles door bell butto. When you press this package bean button, it will give signal in from of visual representation. I have used the  traditional "bell" picture (also attached with this code) to represent door bell. This sign is prevalent for all the bells including door bells. So when visitor is using door bell, the picture of bell will be displayed on the screen of the person with hearing impairment. This application can be scaled for various other mediums like television, projector display etc. Following is the code for the same.

Materials Used: Packaging Beans

import processing.serial.*;
PImage bell;
String portname = "COM3"; // or "COM5"
Serial port;
String buf="";
int cr = 13;  // ASCII return   == 13
int lf = 10;  // ASCII linefeed == 10

void setup()
{
size(500, 500); 
noFill();
noStroke();
frameRate(20);
background(255); 
smooth();
port = new Serial(this, portname, 9600);
}

void draw()
{ }

void bellRung(String imageFile)
{
bell = loadImage(imageFile);
image(bell, 0, 0, width, height);
}

// called whenever serial data arrives
void serialEvent(Serial p)
{
int c = port.read();
if (c != lf && c != cr)
{
buf += char(c);
}
if (c == lf)
{
int val = int(buf);
println("val="+val);
if(val > 100)
{
bellRung("DoorBell.png");
}
else
{
bellRung("nobell.png");

}
buf="";
}
}