LEVEL OF COMPREHENSION:
GENERAL CODING (SEE JAVA)
GENERAL CODING (SEE JAVA)
Canal Convergence 2018 Sample Code Below
Project Bubble Maker Machine Triggering Source Code - (pre-CSE 205)
/*
* Code Written by: Joseph Trevor Avrett
* Portfolio Site: www.trevoravrett.com/
* Access Password: 1209022733
*
* Project: Canal Convergence 2018
* https://canalconvergence.com/
*
* Project Partner: Catharine Lewis
* Project Outline: Build a structure, sized around a +/- 2' cube, that helps convey the meaning/sense of: community
*
* Our project: A puddle-shaped platform, (water = scarce, shared resource, and we're alongside the canal that is our main source
* of water, thus we wanted to do something water-themed) that when you jump on, triggers bubbles to blow out of 3
* 12 volt bubble makers we made, -using lasercut-styrene to form the holding shells and bubble wands,
* (modeled in solidworks, exported to illustrator) and motors and fans we spec'd from a commercial $30-40 bubble maker machine.
* The puddle-shaped platform houses the Arduino, battery, and bubble makers underneath one raised portion of the platform
*
* ASU Herberger Institute for Design and the Arts
* Junior Year of: Industrial Design
* Date: 10/31/18
*/
* Code Written by: Joseph Trevor Avrett
* Portfolio Site: www.trevoravrett.com/
* Access Password: 1209022733
*
* Project: Canal Convergence 2018
* https://canalconvergence.com/
*
* Project Partner: Catharine Lewis
* Project Outline: Build a structure, sized around a +/- 2' cube, that helps convey the meaning/sense of: community
*
* Our project: A puddle-shaped platform, (water = scarce, shared resource, and we're alongside the canal that is our main source
* of water, thus we wanted to do something water-themed) that when you jump on, triggers bubbles to blow out of 3
* 12 volt bubble makers we made, -using lasercut-styrene to form the holding shells and bubble wands,
* (modeled in solidworks, exported to illustrator) and motors and fans we spec'd from a commercial $30-40 bubble maker machine.
* The puddle-shaped platform houses the Arduino, battery, and bubble makers underneath one raised portion of the platform
*
* ASU Herberger Institute for Design and the Arts
* Junior Year of: Industrial Design
* Date: 10/31/18
*/
int
//ints begin with a lowercase; and I like to make proper all the words, and not underscores as spaces for ints
velostatInput = 0, //serial monitor (9600 baud) //the latest serial input value the Arduino receives from the velostat
//ints begin with a lowercase; and I like to make proper all the words, and not underscores as spaces for ints
velostatInput = 0, //serial monitor (9600 baud) //the latest serial input value the Arduino receives from the velostat
//('Weights stored' are ints to save unneccessary memory/calculation time)
currentWeightStored = 0, //serial monitor (9600 baud) //this value will be the last force-applied (weight/pressure applied to the Velostat)reading by the user. This is used to determine the trigger's threshold
lastWeightStored = 0, //takes on the role of the previous velostatInput, for range comparison
veryLastWeightStored = 0; //takes on the role of the previous lastWeightStored, for range comparison
const int //note: const(ants) can begin with capital letters, and uppercase is encouraged at times when appropriate
//PINS are ALL_CAPS
//Time intervals are all proper, with underscores as spaces
//------------------------INPUT BUFFER------------------------
inputBufferCalibration = 200, //serial monitor (9600 baud) //Approximate Non-User Load of the platform "velostatInput"
inputBufferCalibration = 200, //serial monitor (9600 baud) //Approximate Non-User Load of the platform "velostatInput"
//------------------------PINS [MANIPULATABLE IF PINS ARE RELOCATED]------------------------
VELOSTAT_INPUT_PIN = 3,//pin# //Replaces the Analog pin number of the relay with "VELOSTAT_INPUT_PIN", in the 'functions'/'methods' below
OUTPUT_toRELAY_BUBBLE_MAKERS_PIN = 3, //pin# //Replaces the pin number of the relay with "OUTPUT_toRELAY_BUBBLE_MAKERS_PIN", in the 'functions'/'methods' below
OUTPUT_toRELAY_EL_WIRE_PIN = 5; //pin# //Replaces the pin number of the relay with "OUTPUT_toRELAY_EL_WIRE_PIN", in the 'functions'/'methods' below
const double
//Time intervals are all proper, with underscores as spaces
//------------------------TIME INTERVALS, IN SECONDS------------------------
/* IF DIMMING IS POSSIBLE
*
DimUpDuration = 1, //[MANIPULATABLE] Defines the amount of time it takes to turn on the EL Wire
DimDownDuration = 2, //[MANIPULATABLE] Defines the amount of time it takes to turn off the EL Wire
*
*/
//EL WIRE PULSE: 1 [MANIPULATABLE]
EL_Duration_A = 1.5, //seconds //the duration the powered devices will run for, in *seconds*
EL_Gap_A = 2, //seconds //the duration the powered devices will run for, in *seconds*
//EL WIRE PULSE: 2 [MANIPULATABLE]
EL_Duration_B = 1, //seconds //the duration the powered devices will run for, in *seconds*
EL_Gap_B = 2, //seconds //the duration the powered devices will run for, in *seconds*
/* IF DIMMING IS POSSIBLE
*
DimUpDuration = 1, //[MANIPULATABLE] Defines the amount of time it takes to turn on the EL Wire
DimDownDuration = 2, //[MANIPULATABLE] Defines the amount of time it takes to turn off the EL Wire
*
*/
//EL WIRE PULSE: 1 [MANIPULATABLE]
EL_Duration_A = 1.5, //seconds //the duration the powered devices will run for, in *seconds*
EL_Gap_A = 2, //seconds //the duration the powered devices will run for, in *seconds*
//EL WIRE PULSE: 2 [MANIPULATABLE]
EL_Duration_B = 1, //seconds //the duration the powered devices will run for, in *seconds*
EL_Gap_B = 2, //seconds //the duration the powered devices will run for, in *seconds*
//EL WIRE PULSE: 3 [MANIPULATABLE]
EL_Duration_C = 1, //seconds //the duration the powered devices will run for, in *seconds*
EL_Gap_C = 2, //seconds //the duration the powered devices will run for, in *seconds*
//EL WIRE PULSE: 4[MANIPULATABLE]
EL_Duration_D = 1, //seconds //the duration the powered devices will run for, in *seconds*
EL_Duration_C = 1, //seconds //the duration the powered devices will run for, in *seconds*
EL_Gap_C = 2, //seconds //the duration the powered devices will run for, in *seconds*
//EL WIRE PULSE: 4[MANIPULATABLE]
EL_Duration_D = 1, //seconds //the duration the powered devices will run for, in *seconds*
//[MANIPULATABLE] Few extra seconds of bubble making, after the EL Wires shut off after the last pulse
Extra_Runtime_Buffer = 0, //seconds //the duration the powered devices will run for, in *seconds*
Extra_Runtime_Buffer = 0, //seconds //the duration the powered devices will run for, in *seconds*
Input_Check_Refresh_Rate = 0.1; //seconds //[MANIPULATABLE] this is how often the code is refreshed, thus checking for input, (again) in *seconds*
//this does not the include the "Extra_Runtime_Buffer" of the device, since the "Input_Check_Refresh_Rate" will be nominal
//note: increasing the delay size might marginally affect battery life..?
void setup () {
Serial.begin (9600);
pinMode (OUTPUT_toRELAY_BUBBLE_MAKERS_PIN, OUTPUT);
pinMode (OUTPUT_toRELAY_EL_WIRE_PIN, OUTPUT);
}
void loop () {
velostatInput = analogRead (VELOSTAT_INPUT_PIN); //"velostatInput" input is received from this location
Serial.println (velostatInput); //Output of the serial read from "velostatInput"
velostatInput = analogRead (VELOSTAT_INPUT_PIN); //"velostatInput" input is received from this location
Serial.println (velostatInput); //Output of the serial read from "velostatInput"
currentWeightStored = velostatInput + inputBufferCalibration;
if ( ( currentWeightStored ) > ( (lastWeightStored)*1.5)) //If the latest range of two inputs is greater than 3 times the last range of two inputs, then the user jumped
{
//------------------------Bubble Machines - Turn On------------------------
digitalWrite (OUTPUT_toRELAY_BUBBLE_MAKERS_PIN, LOW); //Relay opens >> 12V power is: ON
if ( ( currentWeightStored ) > ( (lastWeightStored)*1.5)) //If the latest range of two inputs is greater than 3 times the last range of two inputs, then the user jumped
{
//------------------------Bubble Machines - Turn On------------------------
digitalWrite (OUTPUT_toRELAY_BUBBLE_MAKERS_PIN, LOW); //Relay opens >> 12V power is: ON
//------------------------EL Wire - Flickers------------------------
//Main Flash of EL Wire____________________________________________________________________________________________________________________
/* //IF DIMMING IS POSSIBLE
GraduallyBrightenELwire();
*/
//Comment-out of action the line below, if dimming is possible
digitalWrite (OUTPUT_toRELAY_EL_WIRE_PIN, LOW); //3V power to EL Wire is : ON
delay ( (EL_Duration_A)*1000); //Delays future code so the bubble maker runs "EL_Duration_A" amount of seconds (delay 'function'/'method' uses milliseconds .:. (seconds)*(1,000 )
/* //IF DIMMING IS POSSIBLE
GraduallyDimELwire();
*/
//Comment-out of action the line below, if dimming is possible
digitalWrite (OUTPUT_toRELAY_EL_WIRE_PIN, HIGH); //3V power to EL Wire is : OFF
delay ( (EL_Gap_A)*1000); //Delays future code so the bubble maker runs "EL_GAP_A" amount of seconds (delay 'function'/'method' uses milliseconds .:. (seconds)*(1,000 )
GraduallyDimELwire();
*/
//Comment-out of action the line below, if dimming is possible
digitalWrite (OUTPUT_toRELAY_EL_WIRE_PIN, HIGH); //3V power to EL Wire is : OFF
delay ( (EL_Gap_A)*1000); //Delays future code so the bubble maker runs "EL_GAP_A" amount of seconds (delay 'function'/'method' uses milliseconds .:. (seconds)*(1,000 )
//Secondary Flash of EL Wire____________________________________________________________________________________________________________________
/* //IF DIMMING IS POSSIBLE
GraduallyBrightenELwire();
*/
//Comment-out of action the line below, if dimming is possible
digitalWrite (OUTPUT_toRELAY_EL_WIRE_PIN, LOW); //3V power to EL Wire is : ON
delay ( (EL_Duration_B)*1000); //Delays future code so the bubble maker runs "EL_Duration_B" amount of seconds (delay 'function'/'method' uses milliseconds .:. (seconds)*(1,000 )
/* //IF DIMMING IS POSSIBLE
GraduallyDimELwire();
*/
//Comment-out of action the line below, if dimming is possible
digitalWrite (OUTPUT_toRELAY_EL_WIRE_PIN, HIGH); //3V power to EL Wire is : OFF
delay ( (EL_Gap_B)*1000); //Delays future code so the bubble maker runs "EL_GAP_B" amount of seconds (delay 'function'/'method' uses milliseconds .:. (seconds)*(1,000 )
//Tertiary Flash of EL Wire____________________________________________________________________________________________________________________
/* //IF DIMMING IS POSSIBLE
GraduallyBrightenELwire();
*/
//Comment-out of action the line below, if dimming is possible
digitalWrite (OUTPUT_toRELAY_EL_WIRE_PIN, LOW); //3V power to EL Wire is : ON
delay ( (EL_Duration_C)*1000); //Delays future code so the bubble maker runs "EL_Duration_B" amount of seconds (delay 'function'/'method' uses milliseconds .:. (seconds)*(1,000 )
/* //IF DIMMING IS POSSIBLE
GraduallyDimELwire();
*/
//Comment-out of action the line below, if dimming is possible
digitalWrite (OUTPUT_toRELAY_EL_WIRE_PIN, HIGH); //3V power to EL Wire is : OFF
delay ( (EL_Gap_C)*1000); //Delays future code so the bubble maker runs "EL_GAP_A" amount of seconds (delay 'function'/'method' uses milliseconds .:. (seconds)*(1,000 )
//Quaternary Flash of EL Wire____________________________________________________________________________________________________________________
/* //IF DIMMING IS POSSIBLE
GraduallyBrightenELwire();
*/
//Comment-out of action the line below, if dimming is possible
//digitalWrite (OUTPUT_toRELAY_EL_WIRE_PIN, LOW); //3V power to EL Wire is : ON
//delay ( (EL_Duration_D)*1000); //Delays future code so the bubble maker runs "EL_Duration_D" amount of seconds (delay 'function'/'method' uses milliseconds .:. (seconds)*(1,000 )
//digitalWrite (OUTPUT_toRELAY_EL_WIRE_PIN, LOW); //3V power to EL Wire is : ON
//delay ( (EL_Duration_D)*1000); //Delays future code so the bubble maker runs "EL_Duration_D" amount of seconds (delay 'function'/'method' uses milliseconds .:. (seconds)*(1,000 )
/* //IF DIMMING IS POSSIBLE
GraduallyDimELwire();
*/
GraduallyDimELwire();
*/
//Comment-out of action the line below, if dimming is possible
//digitalWrite (OUTPUT_toRELAY_EL_WIRE_PIN, HIGH); //3V power to EL Wire is : OFF
//digitalWrite (OUTPUT_toRELAY_EL_WIRE_PIN, HIGH); //3V power to EL Wire is : OFF
//------------------------Bubble Machines - Turn Off------------------------
delay ( Extra_Runtime_Buffer*1000); //Delays future code so the bubble maker runs "Extra_Runtime_Buffer" amount of seconds (delay 'function'/'method' uses milliseconds .:. (seconds)*(1,000 )
//The duration is implemented here, so kids don't waste all of our bubble-solution by endlessly triggering the motor, (-though that may contribute to better motor life)
//Turn off bubble machines
digitalWrite (OUTPUT_toRELAY_BUBBLE_MAKERS_PIN, HIGH); //Relay closes >> 12V power is: OFF
} else {
//------------------------Redundant lines -- check to make sure all the devices are turned off as they should be (in case a glitch/error occurs)------------------------
digitalWrite (OUTPUT_toRELAY_BUBBLE_MAKERS_PIN, HIGH); //Relay closes >> 12V power is: OFF
digitalWrite (OUTPUT_toRELAY_EL_WIRE_PIN, HIGH); //Relay closes >> 3V power is: OFF
}
digitalWrite (OUTPUT_toRELAY_BUBBLE_MAKERS_PIN, HIGH); //Relay closes >> 12V power is: OFF
digitalWrite (OUTPUT_toRELAY_EL_WIRE_PIN, HIGH); //Relay closes >> 3V power is: OFF
}
veryLastWeightStored = lastWeightStored; //This is used in assessing the older range of two inputs
lastWeightStored = currentWeightStored; //Lastly, the lastWeightStored value needs to be updated
delay ( Input_Check_Refresh_Rate*1000 ); //The code's 'reaction time'/'refresh rate' after everything is completed by the loop iteration, (in seconds)
}
/*
void GraduallyDimELwire()
{
for(double i = HIGH ; i > LOW ; i--) //for loop dims the power to the EL WIRE until OFF
{
digitalWrite (OUTPUT_toRELAY_EL_WIRE_PIN, i); //UNO power output closing >> 3V power is progressing towards: OFF
delay( (HIGH)/(DimDownDuration*1000) ); //dimming duration spans the given interval "DimDownDuration"
}
}
void GraduallyDimELwire()
{
for(double i = HIGH ; i > LOW ; i--) //for loop dims the power to the EL WIRE until OFF
{
digitalWrite (OUTPUT_toRELAY_EL_WIRE_PIN, i); //UNO power output closing >> 3V power is progressing towards: OFF
delay( (HIGH)/(DimDownDuration*1000) ); //dimming duration spans the given interval "DimDownDuration"
}
}
void GraduallyBrightenELwire()
{
for(double i = LOW ; i > HIGH ; i++) //for loop dims the power to the EL WIRE until OFF
{
digitalWrite (OUTPUT_toRELAY_EL_WIRE_PIN, i); //UNO power output closing >> 3V power is progressing towards: OFF
delay( (HIGH)/(DimDownDuration*1000) ); //dimming duration spans the given interval "DimDownDuration"
}
}
*/
{
for(double i = LOW ; i > HIGH ; i++) //for loop dims the power to the EL WIRE until OFF
{
digitalWrite (OUTPUT_toRELAY_EL_WIRE_PIN, i); //UNO power output closing >> 3V power is progressing towards: OFF
delay( (HIGH)/(DimDownDuration*1000) ); //dimming duration spans the given interval "DimDownDuration"
}
}
*/