Archive for the 'They Sensor' Category
Matthew Reed- Light it up

As the light sensor picks up values it turns the led on and off.

Code: void setup() {
  pinMode(ledPin, OUTPUT); // declare the ledPin as an OUTPUT
  Serial.begin(9600); // use the serial port to send the values back to the computer
}
void loop() {
  val = analogRead(potPin); // read the value from the sensor
  Serial.println(val); // print the value to the serial port
  digitalWrite(ledPin, HIGH); // turn the ledPin on
  delay(val); // stop the program for some time
  digitalWrite(ledPin, LOW); // turn the ledPin off
  delay(val); // stop the program for some time
}

Trevor Brand- NES

In my They Sensor project i found a way to interface a NES controller into the arduino. to do this all you have to do is find a NES controller get the pin config from nintendo (which is very easy to find because nintendo released this info) and then solder the wires on. once you have done this you need to convert the binary signal that the controller sends into variables to make it easier to add into code. all that is left is to decide what to do with it I decided just to make lights turn on when certain buttons are pressed.

Here is the code i used and i am going to try and get a video up soon

NESpad_LED

Michael LeBlanc Buttons?

So i made a button that when pressed turns of a light for a period of time but if held will keep the light off. I have a external button and led but the arduino button and led will work as well with the same pin configurations

code

const int buttonPin = 2;
const int ledPin =  13;
int ledState = HIGH;
int buttonState;
int lastButtonState = LOW;
long lastDebounceTime = 0;
long debounceDelay = 50;
void setup() {
pinMode(buttonPin, INPUT);
pinMode(ledPin, OUTPUT);
}
void loop() {
int reading = digitalRead(buttonPin);
if (reading != lastButtonState) {
lastDebounceTime = millis();
}
if ((millis() – lastDebounceTime) > debounceDelay) {
buttonState = reading;
}
digitalWrite(ledPin, buttonState);
lastButtonState = reading;
}

const int buttonPin = 2;   const int ledPin =  13;    int ledState = HIGH;         int buttonState;             int lastButtonState = LOW;

long lastDebounceTime = 0;  long debounceDelay = 50;
void setup() {  pinMode(buttonPin, INPUT);  pinMode(ledPin, OUTPUT);}
void loop() {    int reading = digitalRead(buttonPin);
if (reading != lastButtonState) {
lastDebounceTime = millis();  }     if ((millis() – lastDebounceTime) > debounceDelay) {    buttonState = reading;  }
digitalWrite(ledPin, buttonState);
lastButtonState = reading;}

Picture will be up in a little bit

Geoff, Jeremiah, Toan – The Struggling Project ^^

Since John “accidentally” gave us the Photocell sensors instead of Infrared Sensors. We had to struggle to come up with some sort of ideas to build with the Photocell.

*It’s alright, John, we’re not mad at you. =]*

Here is what Geoff and Jeremiah came up with while they were eating at McDonald’s. All I did was saying thank you after Geoff threatened me, and posting this post on the blog.

When the Ardunio is plugged into the computer, the right light will turn on while the left light is off. As you can see in one of the picture, Geoff’s hand is on the Photocell sensor, and when that happens, the right light will turn off and the left light will turn on.

That is really confusing, I believe. So let’s me rephrase that.

When the Photocell sensor receives no light, it will turn the left light on, and turn the right light off.

Here is the code (Hope you like it) :P

Struggling Sensor

Yay !!! :D
Darren Dawdy-Noise Meter

This is a simple noise meter, where the level of noise is displayed by the LED’s.  Theoretically, this is how it works, but the microphone is not perfectly consistent.  If there is little to no noise, no LED’s will light up.  If there is a low amount of noise, but enough to meet the requirements for the code, then the first pair of LED’s lights up for 1 second, and then off briefly, and back on, as long as the noise level stays the same.  If there is an amount of noise 1 code level up, then the second pair of LED’s lights up, behaving the same as the first pair.  If there is a large enough amount of noise reaching the microphone, then the 2 pairs of LED’s will quickly alternate lighting up, to create an effect that coincides with the noise level.

The wiring is set up based on the example, and the code is roughly based off of the example code on the website.  Additions to the wiring other than what the example showed is only for the LED lights.  Pins 13 and 11 supply the power to each pair of LED’s.

The code: Noise_Meter

long ave;
int sensorValue;
int movingAverage[128];
int pointer = 0;
long LastTime = millis();

void setup() {
  pinMode(13,OUTPUT);
  pinMode(11,OUTPUT);
  Serial.begin(9600);
  for (int i=0; i< 128; i++)
    movingAverage[i] = 0;
}

void loop() {
  sensorValue = analogRead(A0);
  sensorValue = abs(sensorValue-512)*2;
//  sensorValue = CalcAverage(sensorValue);
//  if (LastTime < millis()) { 
//    Serial.println(sensorValue, DEC);
//    LastTime = millis() + 100;
  if (sensorValue<500) {
    digitalWrite(13,LOW);
    digitalWrite(11,LOW);
  }
  if (sensorValue >500&&sensorValue <600) {
    digitalWrite(13,HIGH);
    digitalWrite(11,LOW);
    delay(1000);
    digitalWrite(13,LOW);
    delay(50);
  }
  if (sensorValue >650&&sensorValue<700) {
    digitalWrite(11,HIGH);
    delay(1000);
    digitalWrite(11,LOW);
    delay(50);
  }
  if (sensorValue >700) {
    digitalWrite(13,HIGH);
    digitalWrite(11,LOW);
    delay(100);
    digitalWrite(13,LOW);
    digitalWrite(11,HIGH);
    delay(100);
    digitalWrite(13,HIGH);
    digitalWrite(11,LOW);
    delay(100);
    digitalWrite(13,LOW);
    digitalWrite(11,HIGH);
    delay(100);
    digitalWrite(13,HIGH);
    digitalWrite(11,LOW);
    delay(100);
    digitalWrite(13,LOW);
    digitalWrite(11,HIGH);
    delay(100);
    digitalWrite(13,HIGH);
    digitalWrite(11,LOW);
    delay(100);
    digitalWrite(13,LOW);
    digitalWrite(11,HIGH);
    delay(100);
    digitalWrite(13,HIGH);
    digitalWrite(11,LOW);
    delay(100);
    digitalWrite(13,LOW);
    digitalWrite(11,HIGH);
    delay(100);
  }
}

int CalcAverage(int instantVal)
{
  ave -= movingAverage[pointer];
  movingAverage[pointer] = instantVal;
  ave += instantVal;
  pointer++;
  pointer %= 128;
  return (ave >> 7);
}

Thaiband Nith – led infrared fade

Took some time trying to figure out how to do it, but i got it :)

Well not exactly I wanted it to change colors at certain range of distance, couldn’t quite figure out how to do that.

so if anyone can help me out with that let me know :P

i bought a full color led from radio shack for about 2.99

it says it can change only into 3 colors, red blue and green. but by mixing the power to each prongs ( whatever you wanna call it) or the pins i should say you can change the color. they also sell a 7 color led. its basically the same for 2.49 but cheaper… DANGIT should have went for that.

codes:

const int analogInPin = 0;  // Analog input pin that the sensor is attached to
const int analogOutPin = 10; // Analog output pin that the LED is attached to change pin to 9 for red 10 for blue 11 for green
int sensorValue = 0;        // value read from the pot
int outputValue = 0;        // value output to the sensor (analog out)
void setup() {
// initialize serial communications at 9600 bps:
Serial.begin(9600);
}
void loop() {
// read the analog in value:
sensorValue = analogRead(analogInPin);
// map it to the range of the analog out:
outputValue = map(sensorValue, 15, 90, 0, 25);
// change the analog out value:
analogWrite(analogOutPin, outputValue);
// print the results to the serial monitor:
Serial.print(“sensor = ” );
Serial.print(sensorValue);
Serial.print(“\t output = “);
Serial.println(outputValue);
delay(10);
}

const int analogInPin = 0;  // Analog input pin that the sensor is attached toconst int analogOutPin = 10; // Analog output pin that the LED is attached to change pin to 9 for red 10 for blue 11 for green
int sensorValue = 0;        // value read from the potint outputValue = 0;        // value output to the sensor (analog out)
void setup() {  // initialize serial communications at 9600 bps:  Serial.begin(9600);}
void loop() {  // read the analog in value:  sensorValue = analogRead(analogInPin);  // map it to the range of the analog out:  outputValue = map(sensorValue, 15, 90, 0, 25);  // change the analog out value:  analogWrite(analogOutPin, outputValue);
// print the results to the serial monitor:  Serial.print(“sensor = ” );  Serial.print(sensorValue);  Serial.print(“\t output = “);  Serial.println(outputValue);
delay(10);}

============================================================================================================================

new codes – trying to change the color, still have not succeeded :(

// Analog pin settings
int aIn = 0;    // Potentiometers connected to analog pins 0, 1, and 2
int bIn = 1;    //   (Connect power to 5V and ground to analog ground)
int cIn = 2;
// Digital pin settings
int aOut = 9;   // LEDs connected to digital pins 9, 10 and 11
int bOut = 10;  //   (Connect cathodes to digital ground)
int cOut = 11;
// Values
int aVal = 500;   // Variables to store the input from the sensor
int bVal = 350;
int cVal = 200;
// Variables for comparing values between loops
int i = 0;            // Loop counter
int wait = (1000);    // Delay between most recent pot adjustment and output
int checkSum     = 0; // Aggregate pot values
int prevCheckSum = 0;
int sens         = 3; // Sensitivity theshold, to prevent small changes in
// pot values from triggering false reporting
// FLAGS
int PRINT = 1; // Set to 1 to output values
int DEBUG = 1; // Set to 1 to turn on debugging output
void setup()
{
pinMode(aOut, OUTPUT);   // sets the digital pins as output
pinMode(bOut, OUTPUT);
pinMode(cOut, OUTPUT);
Serial.begin(9600);     // Open serial communication for reporting
}
void loop()
{
i += 1; // Count loop
aVal = analogRead(aIn) / 4;  // read input pins, convert to 0-255 scale
bVal = analogRead(bIn) / 4;
cVal = analogRead(cIn) / 4;
analogWrite(aOut, aVal);    // Send new values to LEDs
analogWrite(bOut, bVal);
analogWrite(cOut, cVal);
if (i % wait == 0)                // If enough time has passed…
{
checkSum = aVal+bVal+cVal;      // …add up the 3 values.
if ( abs(checkSum – prevCheckSum) > sens )   // If old and new values differ
// above sensitivity threshold
{
if (PRINT)                    // …and if the PRINT flag is set…
{
Serial.print(“A: “);        // …then print the values.
Serial.print(aVal);
Serial.print(“\t”);
Serial.print(“B: “);
Serial.print(bVal);
Serial.print(“\t”);
Serial.print(“C: “);
Serial.println(cVal);
PRINT = 0;
}
}
else
{
PRINT = 1;  // Re-set the flag
}
prevCheckSum = checkSum;  // Update the values
if (DEBUG)   // If we want debugging output as well…
{
Serial.print(checkSum);
Serial.print(“<=>”);
Serial.print(prevCheckSum);
Serial.print(“\tPrint: “);
Serial.println(PRINT);
}
}
}
Ali Kazi – Light sensitive light show

Very simple project. It does not add to my final project, this is on its own because my final project doesn’t require a sensor.  I wanted to add sound to this but with 2 tests this morning and lot of work past week, I finished what I could.

Anyway, what I made is a light sensitive LED light show. You might remember my LED project from Us Arduino in which I created runway like lights using a series of LEDs. I still had that the way it was so I decided to add a sensor to that and make something unique with the setup.

This time, the light sensor triggers 4 different LED behaviors depending on the light intensity it is catching. The sensor reads intensity on a range of 0 – 400 units which I directly use as a delay to create the light show. I created 4 different behaviors and divided them on ranges of 100. So between 0-100 theres a specific LED behavior, between 100-200 it is different and so on. So to be able to watch all 4 behaviors you have to expose only the right amount of light to the sensor from total dark to total bright. My cellphone screen works perfectly when combined with its distance from the sensor as I will demonstrate in class presentation tomorrow. Here’s a picture for now and you will see the Live show in class. .PDE file and the code are included.


 

Ali Kazi’s “They sensor” PDE File

 

Code:

int mappedValue;
int sensorPin = A0; // select the input pin for the Light sensor
int x=0;
//There are total of 16 LEDs; each pin controls a pair.
int ledPin1 = 1;
int ledPin2 = 2;
int ledPin3 = 3;
int ledPin4 = 4;
int ledPin6 = 6;
int ledPin7 = 7;
int ledPin8 = 8;

void setup() {
 // declare the sensor pin as INPUT and all LED pins as OUTPUT:
 pinMode(A0, INPUT);
 pinMode(ledPin1, OUTPUT);
 pinMode(ledPin2, OUTPUT);
 pinMode(ledPin3, OUTPUT);
 pinMode(ledPin4, OUTPUT);
 pinMode(ledPin6, OUTPUT);
 pinMode(ledPin7, OUTPUT);
 pinMode(ledPin8, OUTPUT);
}

void loop() {
 //Compress the sensor values of 0 – 1023 to 0 – 400. This is because I am using the sensor reading as delay. So if sensor reads high values, delay will become high and it will bore us to death to look at a slow LED show.
 mappedValue = map(x, 0, 1023, 0, 400);

// read the value from the sensor
 x = analogRead(sensorPin);

//Do the following if light intensity is between 300 and 400 units

do{
 digitalWrite(ledPin1, HIGH);
 x = analogRead(sensorPin);
 digitalWrite(ledPin2, HIGH);
 x = analogRead(sensorPin);
 digitalWrite(ledPin3, HIGH);
 x = analogRead(sensorPin);
 digitalWrite(ledPin4, HIGH);
 x = analogRead(sensorPin);
 digitalWrite(ledPin6, HIGH);
 x = analogRead(sensorPin);
 digitalWrite(ledPin7, HIGH);
 x = analogRead(sensorPin);
 digitalWrite(ledPin8, HIGH);
 x = analogRead(sensorPin);
 delay(x);
 digitalWrite(ledPin1, LOW);
 x = analogRead(sensorPin);
 digitalWrite(ledPin2, LOW);
 x = analogRead(sensorPin);
 digitalWrite(ledPin3, LOW);
 x = analogRead(sensorPin);
 digitalWrite(ledPin4, LOW);
 x = analogRead(sensorPin);
 digitalWrite(ledPin6, LOW);
 x = analogRead(sensorPin);
 digitalWrite(ledPin7, LOW);
 x = analogRead(sensorPin);
 digitalWrite(ledPin8, LOW);
 x = analogRead(sensorPin);
 delay(x);
 }while(x>=300);

//Do the following if light intensity is between 200 and 300 units

do{
 digitalWrite(ledPin1, HIGH);
 delay(x);
 x = analogRead(sensorPin);
 digitalWrite(ledPin2, HIGH);
 delay(x);
 x = analogRead(sensorPin);
 digitalWrite(ledPin3, HIGH);
 delay(x);
 x = analogRead(sensorPin);
 digitalWrite(ledPin4, HIGH);
 delay(x);
 x = analogRead(sensorPin);
 digitalWrite(ledPin6, HIGH);
 delay(x);
 x = analogRead(sensorPin);
 digitalWrite(ledPin7, HIGH);
 delay(x);
 x = analogRead(sensorPin);
 digitalWrite(ledPin8, HIGH);
 delay(x);
 x = analogRead(sensorPin);
 digitalWrite(ledPin8, LOW);
 delay(x);
 x = analogRead(sensorPin);
 digitalWrite(ledPin7, LOW);
 delay(x);
 x = analogRead(sensorPin);
 digitalWrite(ledPin6, LOW);
 delay(x);
 x = analogRead(sensorPin);
 digitalWrite(ledPin4, LOW);
 delay(x);
 x = analogRead(sensorPin);
 digitalWrite(ledPin3, LOW);
 delay(x);
 x = analogRead(sensorPin);
 digitalWrite(ledPin2, LOW);
 delay(x);
 x = analogRead(sensorPin);
 digitalWrite(ledPin1, LOW);
 delay(x);
 x = analogRead(sensorPin);
 }while(x>=200&&x<300);

//Do the following if light intensity is between 100 and 200 units

do{
 digitalWrite(ledPin4, HIGH);
 delay(x);
 x = analogRead(sensorPin);
 digitalWrite(ledPin3, HIGH);
 digitalWrite(ledPin6, HIGH);
 delay(x);
 x = analogRead(sensorPin);
 digitalWrite(ledPin2, HIGH);
 digitalWrite(ledPin7, HIGH);
 delay(x);
 x = analogRead(sensorPin);
 digitalWrite(ledPin1, HIGH);
 digitalWrite(ledPin8, HIGH);
 delay(x);
 x = analogRead(sensorPin);
 digitalWrite(ledPin8, LOW);
 digitalWrite(ledPin1, LOW);
 delay(x);
 x = analogRead(sensorPin);
 digitalWrite(ledPin7, LOW);
 digitalWrite(ledPin2, LOW);
 delay(x);
 x = analogRead(sensorPin);
 digitalWrite(ledPin6, LOW);
 digitalWrite(ledPin3, LOW);
 delay(x);
 x = analogRead(sensorPin);
 digitalWrite(ledPin4, LOW);
 delay(x);
 }while(x>100&&x<200);

//Do the following if light intensity is between 0 and 100 units

do{
 digitalWrite(ledPin1, HIGH);
 delay(x);
 x = analogRead(sensorPin);
 digitalWrite(ledPin1, LOW);
 digitalWrite(ledPin6, HIGH);
 delay(x);
 x = analogRead(sensorPin);
 digitalWrite(ledPin6, LOW);
 digitalWrite(ledPin3, HIGH);
 delay(x);
 x = analogRead(sensorPin);
 digitalWrite(ledPin3, LOW);
 digitalWrite(ledPin8, HIGH);
 delay(x);
 x = analogRead(sensorPin);
 digitalWrite(ledPin8, LOW);
 digitalWrite(ledPin4, HIGH);
 delay(x);
 x = analogRead(sensorPin);
 digitalWrite(ledPin4, LOW);
 digitalWrite(ledPin7, HIGH);
 delay(x);
 x = analogRead(sensorPin);
 digitalWrite(ledPin7, LOW);
 digitalWrite(ledPin2, HIGH);
 delay(x);
 x = analogRead(sensorPin);
 digitalWrite(ledPin2, LOW);
 }while(x<=100);
}

Luis Nolasco- They Sensor

Well i was trying to use a sound sensor light an LED whenever a sound was heard. I’m pretty sure my circuitry is correct, but it could be wrong, but i think the main problem is in the code. I’m still not completely understanding it.

IMG_20101115_235118.jpg

this is the code i had

long ave;
int sensorValue;
int movingAverage[128];
int pointer = 0;
long LastTime = millis();
void setup() {
pinMode(13,OUTPUT);
Serial.begin(9600);
for (int i=0; i< 128; i++)
movingAverage[i] = 0;
}
void loop() {
sensorValue = analogRead(A0);
sensorValue = abs(sensorValue-512)*2;
if (sensorValue>1000) {
digitalWrite (13,HIGH);
delay (1000);
digitalWrite (13,LOW);   delay (50);       //when a sound volume of 350 is reached the led in pin 13 turns on for 1 second
}
}
int CalcAverage(int instantVal)
{
ave -= movingAverage[pointer];
movingAverage[pointer] = instantVal;
ave += instantVal;
pointer++;
pointer %= 128;
return (ave >> 7);
}

long ave;int sensorValue;int movingAverage[128];int pointer = 0;long LastTime = millis();
void setup() {  pinMode(13,OUTPUT);  Serial.begin(9600);  for (int i=0; i< 128; i++)    movingAverage[i] = 0;}
void loop() {  sensorValue = analogRead(A0);  sensorValue = abs(sensorValue-512)*2;  if (sensorValue>1000) {     digitalWrite (13,HIGH);    delay (1000);    digitalWrite (13,LOW);   delay (50);       //when a sound volume of 350 is reached the led in pin 13 turns on for 1 second  }}
int CalcAverage(int instantVal){  ave -= movingAverage[pointer];  movingAverage[pointer] = instantVal;  ave += instantVal;  pointer++;  pointer %= 128;  return (ave >> 7);}

Nick Dunham & Rachel Paletta’s …untitled thing

We used a sensor that measures the time it takes sound waves to travel a certain distance and back, then converts to distance. The program we wrote states that if your hand is a certain distance from the sensor, the solenoid will fire, making the drumstick come down onto the drum. It takes 24v to power the solenoid.

Our plan is to make about 10+ of these, but using a teeter-totter set up to make an actual drum noise, and make them our final project. We got the idea from Tom:

http://www.youtube.com/tomtechart#p/u/28/1TBiSHqk0MY

But our drums will go off using a motion/light sensor, instead of pushing a button.

(inserted in the solenoid is a stick with a bouncy ball attached to the end. Nick has the project and I don’t have a completed photo of it)

Seth Simon’s Tripwire Jingle!

I used a photocell and  a laser to make the trip. The laser simple shines on the photocell and when someone passes by the light from the laser no longer shines on the photocell. then this triggers the music from the speaker playing Jingle Bells. I originally wanted to use a motion sensor to make the music play but the added affect of a laser was way more appealing to me!

This project was very simple to build all i used was the melody program from the arduino examples to make the music and for the switch I used an if statement to switch the music on when the light no longer shined on the photocell.

Here is a video! sorry if the sound is not great.

The VIDEO!!!

Here is the code I used !!

/*
  AnalogReadSerial
 Reads an analog input on pin 0, prints the result to the serial monitor
 
 This example code is in the public domain.
 */
int whole_note = 1600;
 int half_note = 800;
int quarter_note = 400;
int ledPins[] = {
  2, 3,4,5 };    
int pinCount = 6;

void setup() {
  Serial.begin(9600);
 
  int thisPin;
 
 for (int thisPin = 0; thisPin < pinCount; thisPin++)  {
    pinMode(ledPins[thisPin], OUTPUT);     
 }
}

void loop() {
  int sensorValue = analogRead(A0);
  Serial.println(sensorValue, DEC);
 
  if (sensorValue<900) {

  for(int count=0; count<2; count++){
  tone(6, 330, quarter_note); //E

  delay(quarter_note);

  noTone(6);
  tone(6, 330, quarter_note); //E
  delay(quarter_note);
  noTone(6);
  tone(6, 330,half_note); //E half not
  delay(half_note);
  noTone(6);
  }
 
  tone(6, 330, quarter_note); //E
  delay(quarter_note);
  noTone(6);
  tone(6, 392, quarter_note); //G
  delay(quarter_note);
  noTone(6);
  tone(6, 262, quarter_note); //C
  delay(quarter_note);
  noTone(6);
  tone(6, 294, quarter_note); //D
  delay(quarter_note);
  noTone(6);
 
  tone(6, 330, whole_note); //E
  delay(whole_note);
  noTone(6);
 
  for(int count=0; count<5; count++){
   tone(6, 349, quarter_note); //F
  delay(quarter_note);
  noTone(6);
  }
 
  for(int count=0; count<3; count++){
  tone(6, 330, quarter_note); //E
  delay(quarter_note);
  noTone(6);
  }
 
  for(int count=0; count<2; count++){
  tone(6, 392, quarter_note); //G
  delay(quarter_note);
  noTone(6);
  }
 
  tone(6, 349, quarter_note); //F
  delay(quarter_note);
  noTone(6);
 
  tone(6, 330, quarter_note); //E
  delay(quarter_note);
  noTone(6);
 
  tone(6,262, whole_note); //C
  delay(whole_note);
  noTone(6);
  }

}