SpongeBob SquarePants and the bottle
Description
This setup catches the attention of the user by a pulsing LED. To turn the LED off, the user has to remove the cap of the bottle. Now that the users' attention he discovers SpongeBob SquarePants lying around. The user might be intrigued when he also notices the wire coming from underneath SpongeBob. The user pushes SpongeBob and discovers the movement on the screen - "it's SpongeBob and he talks!?!"
Components used
- Breadboard
- Arduino Uno
- Blue LED
- 2 resisters
- Plastic bottle
- Photo cell
- Force cell
- Duck tape
- Eraser SpongeBob
Arduino code
/*
/This example shows the output of an analogRead() of a Photocell.
/By M.Gonzalez
/www.codingcolor.com
/ Modified by Soren Svejstrup 2/26/13
/ It now transporms the input from a photocell to a blinking LED
/ And it reads the input from a force sensor. The indput is sent to
/ the Serial
*/
int photocellPin = 0; // Photocell connected to analog pin 0
int forcePin = 1; // Photocell connected to analog pin 1
int photocellVal = 0; // define photocell variable
int forceVal = 0; // define force sensor variable
int ledPin = 10;// LED connected to digital pin 10
int ledState = 0;//state of the led
int fadeDown = 30;//delay per fade
int fadeUp = 30;//delay per fade
int minLight = 700;//min light threshold
void setup() {
Serial.begin(9600);
pinMode(photocellPin, INPUT);
pinMode(forcePin, INPUT);
pinMode(ledPin, OUTPUT);
}
void loop() {
photocellVal = analogRead(photocellPin);
forceVal = analogRead(forcePin);
Serial.println(forceVal);
//Serial.println(photocellVal);
if (photocellVal < minLight){
fadeLed(1);
// Serial.println("fade");
}
}
// This function controlls the fading up and down of the LED
void fadeLed(int num){
if (num == 1){
for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=7) {
analogWrite(ledPin, fadeValue);
delay(fadeUp);
}
for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=7) {
analogWrite(ledPin, fadeValue);
delay(fadeDown);
}
ledState = 1;
}
}
Processing code
/*
/ This program draws Sponge Bob
/ and allows the user to control
/ the movement of his mouth
/
*/
import processing.serial.*;
Serial port;
float ctrl = 0;
void setup() {
size(500,500);
port = new Serial(this, "/dev/tty.usbmodem621", 9600);
port.bufferUntil('\n');
}
void draw() {
background(100, 149, 237);
// the body
rectMode(CENTER);
fill(255, 255, 0);
rect(250,250,200,300);
// the shirt
fill(255, 255, 255);
rect(250,355,200,80);
// the pants
fill(139, 69, 19);
rect(250,375,200,50);
// the white ind the eyes
fill(224, 255, 255);
ellipse(200,140,40,43);
ellipse(300,140,40,43);
// the blue ind the eyes
fill(100, 149, 237);
ellipse(200,130,20,22);
ellipse(300,130,20,22);
// the black ind the eyes
fill(0, 0, 0);
ellipse(200,130,10,12);
ellipse(300,130,10,12);
// the arms
fill(255, 255, 0);
line(100,135,150,200);
line(350,200,400,135);
// the legs
fill(255, 255, 0);
line(200,400,190,450);
line(300,400,310,450);
// the mouth
fill(95, 2, 31);
ellipse(250, 220, 100, ctrl);
}
void serialEvent (Serial port) {
ctrl = float(port.readStringUntil('\n'));
}
- Login to post comments
Drupal theme by Kiwi Themes.