The inspiration for our project came as a video about socially awkward small public spaces, like an elevator. Here is the link to the video that we found both amusing and very truthful, as elevators are usually great examples of places where people avoid interactions:
IDEA: Our final prototype represents a tile, that can be assembled into a larger installation or used by itself. Each tile is subdivided into smaller squares (in our case), or any other shapes. A microphone is built in into each subdivided piece and a simple LED circuit. When the microphone closest to the noise object detects the noise, the LED, associated with this microphone begins to react. The overall effect is an illusion, that an individual tile is associated with a particular person being at the moment in the elevator.
Final Prototype is a pair of shoes, one is the input and local output, and the other "sister shoe" is the remote output.
Input:
Piezo tab
Output:
LED's and Sound
Setup:
Code:
int analogPin = 3; int ledPin = 2; int ledPin2 = 3; int ledPin3 = 4; int ledPin4 = 5; int ledPin5 = 6; int ledPin6 = 7; int ledPin7 = 8; int ledPin8 = 9; int speaker = 10; int val = 0; int tempo = 300;
void c () { // Presets the note "c" to be used later digitalWrite(speaker, HIGH); delayMicroseconds(3830); digitalWrite(speaker, LOW); delayMicroseconds(1915); } void d () { digitalWrite(speaker, HIGH); delayMicroseconds(1700); digitalWrite(speaker, LOW); delayMicroseconds(3400); } void e () { digitalWrite(speaker, HIGH); delayMicroseconds(1519); digitalWrite(speaker, LOW); delayMicroseconds(3038); } void f () { digitalWrite(speaker, HIGH); delayMicroseconds(1432); digitalWrite(speaker, LOW); delayMicroseconds(2864); } void g () { digitalWrite(speaker, HIGH); delayMicroseconds(1275); digitalWrite(speaker, LOW); delayMicroseconds(2550); } void a () { digitalWrite(speaker, HIGH); delayMicroseconds(1136); digitalWrite(speaker, LOW); delayMicroseconds(2272); } void b () { digitalWrite(speaker, HIGH); delayMicroseconds(1014); digitalWrite(speaker, LOW); delayMicroseconds(2028); } void C () { digitalWrite(speaker, HIGH); delayMicroseconds(956); digitalWrite(speaker, LOW); delayMicroseconds(1912); } const int numReadings = 10;
int readings[numReadings]; int index = 0; int total = 0; int average = 0;
void setup() { Serial.begin(9600);
for (int thisReading = 0; thisReading < total =" total" total =" total" index =" index">= numReadings) index = 0; average = total / numReadings;
if (average > 300) {digitalWrite(ledPin,HIGH); c();} else {digitalWrite(ledPin,LOW);}
if (average > 300) {digitalWrite(ledPin2,HIGH); d();} else {digitalWrite(ledPin2,LOW);}
if (average > 400) {digitalWrite(ledPin3,HIGH); e();} else {digitalWrite(ledPin3,LOW);}
if (average > 500) {digitalWrite(ledPin4,HIGH); f();} else {digitalWrite(ledPin4,LOW);}
if (average > 600) {digitalWrite(ledPin5,HIGH); g();} else {digitalWrite(ledPin5,LOW);}
if (average > 700) {digitalWrite(ledPin6,HIGH); a();} else {digitalWrite(ledPin6,LOW);}
if (average > 800) {digitalWrite(ledPin7,HIGH); b();} else {digitalWrite(ledPin7,LOW);}
if (average > 900) {digitalWrite(ledPin8,HIGH); C();} else {digitalWrite(ledPin8,LOW);}
We took Prototype #11 and wired the LED's to our shoe prototype, and connected the Arduino to a 9V battery to make it portable.
Input:
Piezo Tab
Output:
8 LED's and Piezo knock element
Result:
Prototype with Sound output:
Code:
int analogPin = 3; int ledPin = 2; int ledPin2 = 3; int ledPin3 = 4; int ledPin4 = 5; int ledPin5 = 6; int ledPin6 = 7; int ledPin7 = 8; int ledPin8 = 9; int speaker = 10; int val = 0; int tempo = 300;
void c () { // Presets the note "c" to be used later digitalWrite(speaker, HIGH); delayMicroseconds(3830); digitalWrite(speaker, LOW); delayMicroseconds(1915); } void d () { digitalWrite(speaker, HIGH); delayMicroseconds(1700); digitalWrite(speaker, LOW); delayMicroseconds(3400); } void e () { digitalWrite(speaker, HIGH); delayMicroseconds(1519); digitalWrite(speaker, LOW); delayMicroseconds(3038); } void f () { digitalWrite(speaker, HIGH); delayMicroseconds(1432); digitalWrite(speaker, LOW); delayMicroseconds(2864); } void g () { digitalWrite(speaker, HIGH); delayMicroseconds(1275); digitalWrite(speaker, LOW); delayMicroseconds(2550); } void a () { digitalWrite(speaker, HIGH); delayMicroseconds(1136); digitalWrite(speaker, LOW); delayMicroseconds(2272); } void b () { digitalWrite(speaker, HIGH); delayMicroseconds(1014); digitalWrite(speaker, LOW); delayMicroseconds(2028); } void C () { digitalWrite(speaker, HIGH); delayMicroseconds(956); digitalWrite(speaker, LOW); delayMicroseconds(1912); } const int numReadings = 10;
int readings[numReadings]; int index = 0; int total = 0; int average = 0;
4 LED's light up sequentially in response to the act of bending the piezo tab .
INput:
Piezo Tab
OUTput:
4 LED's
Setup:
Prototype #10
Prototype #11
Code:
int analogPin = 3; int ledPin = 2; int ledPin2 = 3; int ledPin3 = 4; int ledPin4 = 5; int ledPin5 = 6; int ledPin6 = 7; int ledPin7 = 8; int ledPin8 = 9; int speaker = 10; int val = 0; int tempo = 300;
void c () { // Presets the note "c" to be used later digitalWrite(speaker, HIGH); delayMicroseconds(3830); digitalWrite(speaker, LOW); delayMicroseconds(1915); } void d () { digitalWrite(speaker, HIGH); delayMicroseconds(1700); digitalWrite(speaker, LOW); delayMicroseconds(3400); } void e () { digitalWrite(speaker, HIGH); delayMicroseconds(1519); digitalWrite(speaker, LOW); delayMicroseconds(3038); } void f () { digitalWrite(speaker, HIGH); delayMicroseconds(1432); digitalWrite(speaker, LOW); delayMicroseconds(2864); } void g () { digitalWrite(speaker, HIGH); delayMicroseconds(1275); digitalWrite(speaker, LOW); delayMicroseconds(2550); } void a () { digitalWrite(speaker, HIGH); delayMicroseconds(1136); digitalWrite(speaker, LOW); delayMicroseconds(2272); } void b () { digitalWrite(speaker, HIGH); delayMicroseconds(1014); digitalWrite(speaker, LOW); delayMicroseconds(2028); } void C () { digitalWrite(speaker, HIGH); delayMicroseconds(956); digitalWrite(speaker, LOW); delayMicroseconds(1912); } const int numReadings = 10;
int readings[numReadings]; int index = 0; int total = 0; int average = 0;
As the Piezo tab is bent, the Piezo element buzzer produces a tone that increases with the amount of force applied to the tab.
Input:
Piezo tab
Output:
Piezo buzzer
Setup:
Result:
Code:
int analogPin = 3; // potentiometer wiper (middle terminal) connected to analog pin 3 // outside leads to ground and +5V int ledPin = 13; // LED connected to digital pin 9 int val = 0; // variable to store the value read void setup() { Serial.begin(9600); // setup serial pinMode(ledPin, OUTPUT); // sets the pin as output } void loop() { val = analogRead(analogPin)/4; // read the input pin Serial.println(val); // debug value val = analogRead(analogPin); // read the input pin digitalWrite(ledPin, val / 4); // analogRead values go from 0 to 1023, analogWrite values from 0 to 255 }
By bending the piezo tab back and forth we are now able read variable output values in the serial monitor in Arduino interface.
Input:
Piezo Film
Output:
Serial read of values in Arduino
Setup:
Result:
Code:
int analogPin = 3; // potentiometer wiper (middle terminal) connected to analog pin 3 // outside leads to ground and +5V int ledPin = 13; // LED connected to digital pin 9 int val = 0; // variable to store the value read void setup() { Serial.begin(9600); // setup serial pinMode(ledPin, OUTPUT); // sets the pin as output } void loop() { val = analogRead(analogPin)/4; // read the input pin Serial.println(val); // debug value val = analogRead(analogPin); // read the input pin digitalWrite(ledPin, val / 4); // analogRead values go from 0 to 1023, analogWrite values from 0 to 255 }
analogPullup(0, true); // enable the 20kOhm pull-up on analog pin 0 }
void loop() { // read the analog input into a variable: int analogValue = analogRead(0); // print the result: Serial.println(analogValue); // wait 10 milliseconds for the analog-to-digital converter // to settle after the last reading: delay(200); //slow enough to examine the values. Yell registers higher than 500 at about 1023. }
2.
potential processing code (with amplifier:LM386, an op-amp):
/* * Monitor for sound sensor */
int potPin = 2; // select the input pin for sound sensor int ledPin = 13; // select the pin for the LED int val = 0; int amp = 0;
void setup() { pinMode(ledPin, OUTPUT); // declare the ledPin as an OUTPUT }
analogPullup(0, true); // enable the 20kOhm pull-up on analog pin 0 }
void loop() { // read the analog input into a variable: int analogValue = analogRead(0); // print the result: Serial.println(analogValue); digitalWrite(cleared, HIGH); pinMode(cleared, OUTPUT); // wait 10 milliseconds for the analog-to-digital converter // to settle after the last reading: delay(200); //slow enough to examine the values. Yell registers higher than 500 at about 1023. }
1. how can we reverse the values because right now the more you distort the film the closer to zero you get
2. we are getting a series of what we believe to be live values....we need to be able to store them (I think it is best we do this in processing)
int analogPin = 3; // potentiometer wiper (middle terminal) connected to analog pin 3 // outside leads to ground and +5Vint ledPin = 9; // LED connected to digital pin 9 int val = 0; // variable to store the value read void setup(){ Serial.begin(9600); // setup serial pinMode(ledPin, OUTPUT); // sets the pin as output} void loop(){ val = analogRead(analogPin); // read the input pin Serial.println(val); // debug value val = analogRead(analogPin); // read the input pin digitalWrite(ledPin, val / 4); // analogRead values go from 0 to 1023, analogWrite values from 0 to 255}
ok..... so on that note.....
how can we make this a bit louder
AND
in processing:
/** * Simple Read * * Read data from the serial port and change the color of a rectangle * when a switch connected to a Wiring or Arduino board is pressed and released. * This example works with the Wiring / Arduino program that follows below. */ import processing.serial.*; Serial myPort; // Create object from Serial classint val; // Data received from the serial port void setup() { size(600, 600); // I know that the first port in the serial list on my mac // is always my FTDI adaptor, so I open Serial.list()[0]. // On Windows machines, this generally opens COM1. // Open whatever port is the one you're using. String portName = Serial.list()[1]; myPort = new Serial(this, portName, 9600);} void draw(){ if ( myPort.available() > 0) { // If data is available, val = myPort.read(); // read it and store it in val } background(255); // Set background to white if (val == 0) { // If the serial value is 0, fill(0); // set fill to black } else { // If the serial value is not 0, fill(204); // set fill to light gray } rect(50, 50, 100, 100);}
/* // Wiring / Arduino Code// Code for sensing a switch status and writing the value to the serial port. int switchPin = 4; // Switch connected to pin 4 void setup() { pinMode(switchPin, INPUT); // Set pin 0 as an input Serial.begin(9600); // Start serial communication at 9600 bps} void loop() { if (digitalRead(switchPin) == HIGH) { // If switch is ON, Serial.print(1, BYTE); // send 1 to Processing } else { // If the switch is not ON, Serial.print(0, BYTE); // send 0 to Processing } delay(100); // Wait 100 milliseconds} */
this is reading the serial port of processing (with the same set up as seen above)
here the color of the serial port changes based on a value....i think this is a one time reading....
either that or...the values are reading too fast....
so
questions:
1. how can we slow down the values
2. how can we store the values.... i think using an array and/or witing a variable
3. how to interpret this data as audio output
- an echo...repeating the original input....(information repeated based on time variable)
or
- a tonal value....(a note produced at a specific frequency based on the value collected)
ie: the higher the value the higher the pitch (a direct relationship of the average values)
/* * YYZ * * Based on the basic Arduino example, Blink: http://www.arduino.cc/en/Tutorial/Blink * Plays the opening rhythm to YYZ by Rush. */
constint LED_PIN = 13; // LED connected to digital pin 13 constint TEMPO = 100; // Beats per minute (the original song is // played at 104 BPM but that's // a little too fast to watch so it has //been slowed down to 100 BPM)
void setup() // Run once, when the sketch starts { pinMode(LED_PIN, OUTPUT); // Sets the digital pin as output }
void loop() // Run over and over again { // Rush: YYZ (-.--|-.--|--..) PlayNote(EIGHTH_NOTE); PlayNote(SIXTEENTH_NOTE); PlayNote(EIGHTH_NOTE); PlayNote(EIGHTH_NOTE); // ---- PlayNote(EIGHTH_NOTE); PlayNote(SIXTEENTH_NOTE); PlayNote(EIGHTH_NOTE); PlayNote(EIGHTH_NOTE); // ---- PlayNote(EIGHTH_NOTE); PlayNote(EIGHTH_NOTE); PlayNote(SIXTEENTH_NOTE); PlayNote(SIXTEENTH_NOTE); }
void PlayNote(int nDuration) { nDuration = (nDuration / 2); digitalWrite(LED_PIN, HIGH); // Set the LED on delay(nDuration); // Wait for half the (original) duration digitalWrite(LED_PIN, LOW); // Set the LED off delay(nDuration); // Wait for half the (original) duration }
2. We searched for similar projects online and here are the scripts we found and our comments on results:
1.
int pinMode(potPin, INPUT);
int potpin = 2
void setup() // run once, when the sketch starts
{
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
pinMode(potPin, INPUT);
}
void loop() // run over and over again
{
Serial.println(analogRead(ledPin));
}
Result: the value does not change on the bottom of the screen.
2.
int potpin = 2
void setup()// run once, when the sketch starts
{
Serial.begin(9600);// opens serial port, sets data rate to 9600 bps
digitalWrite(potPin+14,LOW); // make sure that pull up resistor is disabled -- this is usually not necessary
pinMode(potPin+14, INPUT); // set input mode for ADC pin potPin -- this is usually not necessary
}
void loop()// run over and over again
{
Serial.println(analogRead(potPin));
}
Result: no changes
3.
int ledPin = 13;
int potPin = 2; // connected to speaker output pc
int val = 0; // variable to store the value coming from the sensor
void setup() {
pinMode(ledPin, OUTPUT); // declare the ledPin as an OUTPUT
}
void loop() {
val = analogRead(potPin); // read the value from the sensor or audio input
digitalWrite(ledPin, HIGH);
delay(val);
digitalWrite(ledPin, LOW);
delay(val); // stop the program for some time
}
Result: after modifying the script slightly we see the led respond to loud noise, but the led stays on and blinks even if no noise is made. Tried to modify the script further, no changes.
4.
int ledPin = 13;
int potPin = 2; // connected to speaker output pc
int val = 0; // variable to store the value coming from the sensor
int avg = 0;
void setup() {
pinMode(ledPin, OUTPUT); // declare the ledPin as an OUTPUT
pinMode(potPin, INPUT);
}
void loop() {
val = analogRead(potPin); // read the value from the sensor or audio input
avg = (avg * 127L + val) / 128; // *duck* i dont know what kind of average this is... :-)
digitalWrite(ledPin, avg > 100 ? HIGH : LOW); // use lower border for more HIGH-time
delay(10); // use lower delay, if it doesnt flicker enough
}
Result: no changes
3. Nothing we did affected the value at the bottom of the screen. At some point the led did react to the sound, so that means the microphone does work. Here is the image of the hook up we had, which we also changed to test and
We have decided earlier that we have been looking toward applying our prototype in a public bathroom or elevator. Both environments are known to have awkward social interactions and behaviors. A way to affect the normal behavior and experience of the human in these environments, conversation and voice vibration is encouraged in order to affect the environment and to direct people away from awkwardness. The intensity or hue of the lighting of the area will be affected by the encouragement of conversation and interaction.
So we started of with this prototype and hope to continue on :
GOAL: Applying vibration to Piezo Vibration Sensor affect LED intensity.
PROCESS: Connected Piezo Vibration Sensor and LED. Tapping on Sensor or surface the arduino is placed on.
RESULT: Vibration of the sensor by tapping resulted in blinking of the LED.
1] We’re having problems with the 2nd iteration of the Code. Is there a way that we can have it revised?
2] How can we really add more than one input and output source on each individual Arduino?
3] How can we get a percentage instead of a 230-something value that we receive from the LED light sensor for comparing it with another input source?
4] If we are able to read gas (Methane, CO2). Can we represent the data as an output using pressurized air bottles? (the ones that are used for cleaning keyboards)
a problem: pachube is live feed exchange....how can we store values from arduino... to be used at a later time (ie: download info per day)How do we vary the code so that it add the previous value?
1. Sim to tutorial 2: getting a value from an LED to pachube: How do we get a value from the piezo onto pachube.... can we just replace piezo with LED light sensor? How do we edit the code do be specific about what the value is measuring?
2. Need code to transfer data from pachube back to arduino - how can we convert pachube output value into variations of audio outputs... - Do we use the same piezo buzzer as the output or do we need to have two piezi per shoe? - example: changing speed of beats or frequency Does pachube repeat a series of values....or an average?
This is current map came to be the background for our project.
We have build a successful prototype that was able to receive data trough Pachube and display it with a set of two circuits with red LED's, form which each one displayed data form a different place in the world. First, used a feed form Cambridge University and the second one received the same data category form Syracuse, New York. We have chosen these two places because we have decided that they have provided the best data.
Unluckily we have not realized that those two places have quite similar weather conditions during this time in the year, therefore intensity of light was very similar and it was hard to determine the difference.
Another prototype, which we have worked on as well was the RGB LED circuit that was to change from Blue to REd and back with a certain timing. We have also experimented with other colors but they were not displayed with a good enough clarity and therefore we have decided that blue-red-blue change will not cause the confusion other colors would.
Ideally, two prototypes would be combined and current real-time data form a feed would be compared to the past information (average temperature for that same day x years ago).
Using Arduino Board and recollecting temperature, light, humidity, wind, and precipitation data from one specific place and transmitting it through the Internet using Pachube. That numeric data mimics the environment from a remote location turning on a fan, a light, a water mister, a heater.
Light Sensor Code (Sending Data to Pachube)
Possibilities
MAIN
Our main purpose for this project will result on an installation replicating two different conditions on two interior spaces in Brooklyn. The expectations of expandability of the project will be the expression of five different Pachube feeds, preferably from international locations.
The Greenhouse is a glass building that protects plants from the cold environment. But, what if the plants that we grow have the precise environmental con
ditions from the place that they are endemic? The result: more effective agriculture.
An example of this could be if Kendra has the most important reunion about a 1 Billion-Dollar project in Dubai in two weeks. She needs to be ready and alert for this significant meeting. The solution: Replicate Dubai environment at home in Brooklyn two days before the
flight. The result: Kendra will be well rested and ready to be successful.
INSTALLATION - ATTRACTION
On a largest scale, what if we would like to replicate the exact Antarctica, or Istanbul environment on a controlled location for people to enjoy and travel just by opening and closing doors? What if we could replicate Beijing’s Pollution or Sahara’s Snow Storms on a minute-by-minute updating?
ANIMAL/PLANT TRANSPORTATION
How to transport a Penguin from the South Pole to New York without the animal being affected? In which way the endangered Flying Witch Plant from the Atacama Desert in Chile can be transported without been affected to another location with similar environmental conditions? The solution:creating a transportation crate that assimilates the conditions in which the living organism resides.
Prototyping
Two (2) Environments :: Two (2) Data
Pachube enables us to get two or more inputs on the same feed. We are tracking down lighting conditions and translating them into numbers. With that we are trying to dim a LED on the two different Arduino Boards on two different rooms. We are recollecting Data and the next step is to represent that data on the opposite Arduino Board. After we get the Sensor/Dimmable Light to work, we will be able to control temperature and ventilation very easily.
GOAL: Create a circuit that would change intensity of the LED light depending on the specific conditions.
PROCESS: Created a simple circuit with 100 OM resistor and a one color LED.
RESULT: Although it is hard to see, the LED changes the intensity of the light. When running the script, the output numbers vary by 1 to 3 numbers, which is insignificant and therefore does not produce clearly noticeable change in light intensity.
CODE:
import processing.serial.*;
import cc.arduino.*;
import eeml.*;
Arduino arduino;
int myValue;
DataIn dIn;
void setup()
{
size(255,255);
println(Arduino.list());
arduino = new Arduino(this, Arduino.list()[1], 115200);
dIn = new DataIn(this,"http://www.pachube.com/api/feeds/536.xml", "cb5ac556b416f518567ee5dfec0d9af7cad7a444b52e5e662e796205ca63f7f7", 5000);
Description: We have taken our portable Prototype #6 and adapted it to become 'wearable'. We switch our input back to the piezo element due to its robustness and ease of adaptability for the shoe.
Input: Tapping of the shoe
Output: LED turns ON and OFF
Setup:
Result:
Code: /* Knock Sensor * ---------------- * * Program using a Piezo element as if it was a knock sensor. * * We have to basically listen to an analog pin and detect * if the signal goes over a certain threshold. If the Threshold * is crossed, and toggles the LED on pin 13. * * Modified from one by (cleft) 2005 D. Cuartielles for K3 */
int ledPin = 13; int knockSensor = 2; byte val = 0; int statePin = LOW; int THRESHOLD = 1; // if it's too sensitive then change this value
void setup() { pinMode(ledPin, OUTPUT); }
void loop() { val = analogRead(knockSensor); if (val >= THRESHOLD) { // check the piezo statePin = !statePin; // sets the pin to the opposite state digitalWrite(ledPin, statePin); // turn on or off the LED } }
Description: Using a 9V battery we have transformed our prototype into a portable device!!!
With this version we are testing a different kind of piezo tab, and not achieving the same results as the previous prototype. The LED is definitely responding, but does not have a clear ON and OFF output. The code is the same as Prototype #5 to start, and we adjust the THRESHOLD int, but does not seem to help.
Input: Piezo film, different type than Prototype #5
Output: LED response, not as clear as Prototype #5 output
Setup:
Result:
Code:
/* Knock Sensor * ---------------- * * Program using a Piezo element as if it was a knock sensor. * * We have to basically listen to an analog pin and detect * if the signal goes over a certain threshold. If the Threshold * is crossed, and toggles the LED on pin 13. * * Modified from one by (cleft) 2005 D. Cuartielles for K3 */
int ledPin = 13; int knockSensor = 2; byte val = 0; int statePin = LOW; int THRESHOLD = 100; // if it's too sensitive then change this value
void setup() { pinMode(ledPin, OUTPUT); }
void loop() { val = analogRead(knockSensor); if (val >= THRESHOLD) {// check the piezo statePin = !statePin; // sets the pin to the opposite state digitalWrite(ledPin, statePin); // turn on or off the LED } }
Description: We had a mini-breakthrough and got the piezo tab to trigger a response in an LED. One 'flick' of the tab turns the LED on, and another 'flick' turns it off, and so on.
Input: Piezo Film Sensor
Output: LED turning ON and OFF
Setup:
Result:
Code:
/* Knock Sensor * ---------------- * * Program using a Piezo element as if it was a knock sensor. * * We have to basically listen to an analog pin and detect * if the signal goes over a certain threshold. If the Threshold * is crossed, and toggles the LED on pin 13. * * Modified from one by (cleft) 2005 D. Cuartielles for K3 */
int ledPin = 13; int knockSensor = 2; byte val = 0; int statePin = LOW; int THRESHOLD = 100; // if it's too sensitive then change this value
void setup() { pinMode(ledPin, OUTPUT); }
void loop() { val = analogRead(knockSensor); if (val >= THRESHOLD) {// check the piezo statePin = !statePin; // sets the pin to the opposite state digitalWrite(ledPin, statePin); // turn on or off the LED } }
PROCESS: Using the same wiring as in Prototype #3 but a different code.
RESULT: As seen in the video above GOAL has been nearly achieved, because even though without full control on our side LED does perform a smooth and rhythmical transition between RED and BLUE component.
CODE:
//i/o pin declarations int rpin = 9; int gpin = 10; int bpin = 11;
//function prototypes void solid(int r, int g, int b, int t); void fade(int r1, int g1, int b1, int r2, int g2, int b2, int t);
void setup() { //empty }
void loop() { //colour sequence instructions
//Example sequence one: Rainbow fade over 15 seconds: fade(255,0,0,0,255,0,5000); //fade from red to green over 5 seconds fade(0,255,0,0,0,255,5000); //fade from green to blue over 5 seconds fade(0,0,255,255,0,0,5000); //fade from blue to red over 5 seconds }
//function holds RGB values for time t milliseconds void solid(int r, int g, int b, int t) {
//map values - arduino is sinking current, not sourcing it r = map(r, 0, 255, 255, 0); g = map(g, 0, 255, 255, 0); b = map(b, 0, 255, 255, 0);
//function fades between two RGB values over fade time period t //maximum value of fade time = 30 seconds before gradient values //get too small for floating point math to work? replace floats //with doubles to remedy this? void fade(int r1, int g1, int b1, int r2, int g2, int b2, int t) {
PROCESS: Using the same wiring as in Prototype #3 but a different code.
RESULT: As seen in the video above still RED LED light has been obtained. Feels like a step back from prototype #3, this needs further development.
CODE:
int potpin = 2; // Switch connected to digital pin 2
int rpin = 9; int gpin = 10; int bpin = 11; float h; int h_int; int r=0, g=0, b=0;
int val=0;
void h2rgb(float h, int &R, int &G, int &B);
void setup() // run once, when the sketch starts { Serial.begin(9600); // set up Serial library at 9600 bps }
void loop() // run over and over again { val=analogRead(potpin); // Read the pin and display the value //Serial.println(val); h = ((float)val)/1024; h_int = (int) 360*h; h2rgb(h,r,g,b); Serial.print("Potentiometer value: "); Serial.print(val); Serial.print(" = Hue of "); Serial.print(h_int); Serial.print("degrees. In RGB this is: "); Serial.print(r); Serial.print(" "); Serial.print(g); Serial.print(" "); Serial.println(b);
1.
inline void digitalPullup(byte pin, boolean b) { pinMode(pin, INPUT); digitalWrite(pin, b?HIGH:LOW); }
#if defined(__AVR_ATmega1280__)
inline void analogPullup(byte pin, boolean b) { digitalPullup(pin+54,b); }
#else
inline void analogPullup(byte pin, boolean b) { digitalPullup(pin+14,b); }
#endif
void setup() {
Serial.begin(9600);
pinMode(clearred, OUTPUT);
pinMode(red, OUTPUT);
pinMode(green, OUTPUT);
analogPullup(0, true); // enable the 20kOhm pull-up on analog pin 0
}
void loop() {
// read the analog input into a variable:
int analogValue = analogRead(0);
// print the result:
Serial.println(analogValue);
// wait 10 milliseconds for the analog-to-digital converter
// to settle after the last reading:
delay(200); //slow enough to examine the values. Yell registers higher than 500 at about 1023.
}
2.