Don't wanna be here? Send us removal request.
Photo
Flash Detector with Analog Interrupt Code
int flashes = 0;
int wait = 1000;
void setup()
{
pinMode(7,INPUT);
pinMode(13, OUTPUT);
Serial.begin(9600);
ACSR = B01011010; // comparator interrupt enabled and tripped on falling edge.
digitalWrite(13, HIGH);
}
void loop()
{
for(int i=0; i<flashes; i++)
{
digitalWrite(13, LOW);
delay(100);
digitalWrite(13, HIGH);
delay(100);
}
delay(1000);
}
ISR(ANALOG_COMP_vect)
{
flashes++;
Serial.print("Number of Flashes: ");
Serial.println(flashes);
delay(wait);
}
0 notes
Video
tumblr
Camera Flash around Crown Hall
0 notes
Video
tumblr
The more a door is used the brighter its leds become.
Code:
int wdPin=13;
int edPin=12;
int wHall=0;
int eHall=0;
int westLight=3;
int eastLight=5;
int westCount=0;
int eastCount=0;
int totalCount=0;
int westValue=0;
int eastValue=0;
String wdState=”closed”;
String edState=”closed”;
int maxValue=255;
void setup()
{
pinMode(wdPin, INPUT);
pinMode(edPin, INPUT);
pinMode(eastLight, INPUT);
pinMode(westLight, INPUT);
Serial.begin(9600);
}
void loop()
{
processWest();
processEast();
processCount();
processOutput();
delay(1000);
}
void processWest()
{
wHall = digitalRead(wdPin);
// Serial.println(wHall);
if (wdState.equals(“closed”))
{
if(wHall == HIGH)
{
westCount+=40;
wdState=”open”;
}
}
else
{
if(wHall==LOW)
{
wdState=”closed”;
}
}
}
void processEast()
{
eHall = digitalRead(edPin);
Serial.println(eHall);
if (edState.equals(“closed”))
{
if(eHall == HIGH)
{
eastCount+=40;
edState=”open”;
}
}
else
{
if(eHall==LOW)
{
edState=”closed”;
}
}
}
void processCount()
{
totalCount=eastCount+westCount;
float eastPerc=(float)eastCount/(float)totalCount;
Serial.println(eastPerc);
float westPerc=(float)westCount/(float)totalCount;
Serial.println(westPerc);
if(eastCount>0)
{
eastValue=maxValue*eastPerc;
}
if(westCount>0)
{
westValue=maxValue*westPerc;
}
}
void processOutput()
{
//int westValue = map(westValue, 0, maxValue, 0, 100);
//int eastValue = map(eastValue, 0, maxValue, 0, 100);
analogWrite(westLight,westValue);
analogWrite(eastLight,eastValue);
Serial.print(“West Value: “);
Serial.println(westValue);
Serial.print(“West Count: “);
Serial.println(westCount);
Serial.print(“East Value: “);
Serial.println(eastValue);
Serial.print(“East Count: “);
Serial.println(eastCount);
Serial.print(“Total Count: “);
Serial.println(totalCount);
}
2 notes
·
View notes
Photo
1 note
·
View note
Video
tumblr
As one enters through a door the opposite door glows brighter to attract people and even out usage of both doors (symmetrical usage).
CODE:
int wdPin=13;
int edPin=12;
int wHall=0;
int eHall=0;
int westLight=3;
int eastLight=5;
int westCount=0;
int eastCount=0;
int totalCount=0;
int westValue=0;
int eastValue=0;
String wdState=”closed”;
String edState=”closed”;
int maxValue=255;
void setup()
{
pinMode(wdPin, INPUT);
pinMode(edPin, INPUT);
pinMode(eastLight, INPUT);
pinMode(westLight, INPUT);
Serial.begin(9600);
}
void loop()
{
processWest();
processEast();
processCount();
processOutput();
delay(1000);
}
void processWest()
{
wHall = digitalRead(wdPin);
// Serial.println(wHall);
if (wdState.equals(“closed”))
{
if(wHall == HIGH)
{
eastCount+=40;
wdState=”open”;
}
}
else
{
if(wHall==LOW)
{
wdState=”closed”;
}
}
}
void processEast()
{
eHall = digitalRead(edPin);
Serial.println(eHall);
if (edState.equals(“closed”))
{
if(eHall == HIGH)
{
westCount+=40;
edState=”open”;
}
}
else
{
if(eHall==LOW)
{
edState=”closed”;
}
}
}
void processCount()
{
totalCount=eastCount+westCount;
float eastPerc=(float)eastCount/(float)totalCount;
Serial.println(eastPerc);
float westPerc=(float)westCount/(float)totalCount;
Serial.println(westPerc);
if(eastCount>0)
{
eastValue=maxValue*eastPerc;
}
if(westCount>0)
{
westValue=maxValue*westPerc;
}
}
void processOutput()
{
//int westValue = map(westValue, 0, maxValue, 0, 100);
//int eastValue = map(eastValue, 0, maxValue, 0, 100);
analogWrite(westLight,westValue);
analogWrite(eastLight,eastValue);
Serial.print(“West Value: “);
Serial.println(westValue);
Serial.print(“West Count: “);
Serial.println(westCount);
Serial.print(“East Value: “);
Serial.println(eastValue);
Serial.print(“East Count: “);
Serial.println(eastCount);
Serial.print(“Total Count: “);
Serial.println(totalCount
);
}
1 note
·
View note
Video
tumblr
Using a Piezo sensor to detect vibration. When detected have an alarm sound and a RGB led go off.
2 notes
·
View notes
Video
tumblr
Changing an RGB led with 4 Pots. One of them controlling White, another Red, another Green, then Blue respectively.
The Code:
/*
AnalogReadSerial
Reads an analog input on pin 0, prints the result to the serial monitor.
Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.
This example code is in the public domain.
*/
int Red = 3;
int Green = 5;
int Blue = 6;
// the setup routine runs once when you press reset:
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
pinMode(Red, INPUT);
pinMode(Green, INPUT);
pinMode(Blue, INPUT);
}
// the loop routine runs over and over again forever:
void loop() {
// int intValue1;
//int redValue1;
//int greenValue1;
//int blueValue1;
// read the input on analog pin 0:
int intValue = analogRead(A0);
int redValue = analogRead(A1);
int blueValue = analogRead(A2);
int greenValue = analogRead(A3);
int intValue1 = map(intValue,0,1023,0,6);
int redValue0 = (redValue*intValue1);
int blueValue0 = (blueValue*intValue1);
int greenValue0 = (greenValue*intValue1);
int redValue1 = map(redValue0,0,5115,0,255);
int blueValue1 = map(blueValue0,0,5115,0,255);
int greenValue1 = map(greenValue0,0,5115,0,255);
analogWrite(Red, redValue1);
analogWrite(Green, greenValue1);
analogWrite(Blue, blueValue1);
// print out the value you read:
Serial.print("Intensity");
Serial.print(" ");
Serial.print(intValue1);
Serial.print(" + ");
Serial.print("Red");
Serial.print(" ");
Serial.print(redValue1);
Serial.print(" + ");
Serial.print("Green");
Serial.print(" ");
Serial.print(greenValue1);
Serial.print(" + ");
Serial.print("Blue");
Serial.print(" ");
Serial.println(blueValue1);
delay(1); // delay in between reads for stability
}
1 note
·
View note
Photo
1 note
·
View note
Video
tumblr
Controlling the position of a servo motor with a potentiometer
1 note
·
View note
Video
tumblr
Blinking an LED with a switch and a potentiameter.
1 note
·
View note