Interaction Lab(Moon) Recitation 2: Basic Circuits, Hanlu Zhang (Mary)

  • Instructor: Moon
  • Partner: Lichen Dong
  • Aim:
  • Schematics (http://ima.nyu.sh/interaction-lab/recitation-1-circuits/)
  • Exercise1

    First, we connect the breadboard and DFRduidnio , to give the circuit electric supply.

    Then we put other pieces into the circuit. When we first try, we found only yellow light is working and the switch can’t control the circuit.

So we checked the circuit, try to see whether the LED is in the right direction. Finally we figure out that when connect the DFR and lights, the pins are in the wrong order.

And we did it!

1

  • Exercise 2

The procedure of making one is really smoothly. As some part of the circuit is similar with the last one, we only moved part of the circuit.

Then we finish.

Exercise2

  • Exercise 3

We first connect it by the circuit diagram, and we found it doesn’t work

First we checked whether all the pins are in right place, then we think maybe the photoresists

 is in a wrong order. But it doesn’t. With Jiwon’s help, we find the reason that when we connect power, I connected both the two lines with ground.

Exercise3-1

Then we wonder whether we can control the voicer with photoresists

As these two need different voltage, we first remove the resist.

Then with the help of professor moon, we know that the code for light and voicer are different that voicer need a signal of a value and the signal need to change so that it can make voices, but LED only need a signal to light.

Exercise3-2

Exercise1
/*
   Traffic Light
   This code copied from the book Beginning-Arduino.
*/
int carRed = 12; //assign the car lights
int carYellow = 11;
int carGreen = 10;
int button = 9; //button pin
int pedRed = 8; //assign the pedestrian lights
int pedGreen = 7;
int crossTime =5000; //time for pedestrian to cross
unsigned long changeTime;//time since button pressed

void setup() {
  	pinMode(carRed, OUTPUT);
  	pinMode(carYellow, OUTPUT);
  	pinMode(carGreen, OUTPUT);
  	pinMode(pedRed, OUTPUT);
        pinMode(pedGreen, OUTPUT);
        pinMode(button, INPUT); 
        digitalWrite(carGreen, HIGH); //turn on the green lights
	digitalWrite(pedRed, HIGH); 
}

void loop() {
	int state = digitalRead(button);
        //check if button is pressed and it is over 5 seconds since last button press
        if(state == HIGH && (millis() - changeTime)> 5000){
               //call the function to change the lights
               changeLights();
        }
}

void changeLights() {
	digitalWrite(carGreen, LOW); //green off
	digitalWrite(carYellow, HIGH); //yellow on
	delay(2000); //wait 2 seconds
		
	digitalWrite(carYellow, LOW); //yellow off
	digitalWrite(carRed, HIGH); //red on
        delay(1000); //wait 1 second till its safe
		
	digitalWrite(pedRed, LOW); //ped red off
	digitalWrite(pedGreen, HIGH); //ped green on

	delay(crossTime); //wait for preset time period
		
	//flash the ped green
        for (int x=0; x<10; x++) {
	        digitalWrite(pedGreen, HIGH);
		delay(250);
		digitalWrite(pedGreen, LOW);
		delay(250);
         }
 	  			
        digitalWrite(pedRed, HIGH);//turn ped red on
	delay(500);

	digitalWrite(carRed, LOW); //red off
	digitalWrite(carYellow, HIGH); //yellow on	
	delay(1000);
	digitalWrite(carYellow, LOW); //yellow off
        digitalWrite(carGreen, HIGH); 

	changeTime = millis(); //record the time since last change of lights
	//then return to the main program loop
}
Exercise 2
/*
   Temperature Alarm
*/
float sinVal;            
int toneVal;
unsigned long tepTimer ;    

void setup(){ 
    pinMode(8, OUTPUT);        
    Serial.begin(9600);        
}

void loop(){ 
    int val;               
    double data;          
    val=analogRead(0);  
    data = (double) val * (5/10.24);  // convert the voltage to temperture
     
    if(data>27){        // If the temperture is over 27 degree, buzzer will alarm.  
          for(int x=0; x<180; x++){
            sinVal = (sin(x*(3.1412/180)));
            toneVal = 2000+(int(sinVal*1000));
            tone(8, toneVal);
            delay(2); 
     }   
    } else {    // If the temperturn is below 27 degree, buzzer will not alarm  
           noTone(8);           
    }
     
    if(millis() - tepTimer > 500){     // output the temperture value per 500ms
             tepTimer = millis();
             Serial.print("temperature: ");     
             Serial.print(data);              
             Serial.println("C");              
       } 
}

Exercise3
/*
  Ambient Light controlled LED 
*/
int LED = 13;                     //Led pin
int val = 0;                      

void setup(){
     pinMode(LED,OUTPUT);         
     Serial.begin(9600);        
}

void loop(){
     val = analogRead(0);         // read voltage value 
     Serial.println(val);        
     if(val<1000){                // if the value is less than 1000,LED turns off
          digitalWrite(LED,LOW);
     }else{                        // if the value is more than 1000,LED turns on
          digitalWrite(LED,HIGH);
     }
     delay(10);                   
}

exercise3-2
/*
  Ambient Light controlled LED
*/
int LED = 12;                     //Led pin
int val = 0;

void setup() {
  pinMode(LED, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  val = analogRead(0);         // read voltage value
  Serial.println(val);
  if (val < 1000) {            // if the value is less than 1000,LED turns off
    tone(12, 4000);
    delay(1000);
    //digitalWrite(LED,LOW);
  } else {                       // if the value is more than 1000,LED turns on
    //digitalWrite(LED,HIGH);
    noTone(12);
  }
  delay(10);
}

Interaction Lab(Moon) Recitation 1: Basic Circuits, Hanlu Zhang (Mary)

Interaction Lab Recitation 1

  • Date: September, 8th, 2017
  • Instructor: Moon
  • Partner: Lily wang
  • Aim: Creating three simple circuits on a breadboard based on the circuit diagrams
  • Materials needed: 
    • 1 * Breadboard
    • 1 * LM7805
    • 1 * Buzzer
    • 1 * Push-Button Switch
    • 1 * 220 ohm Resistor
    • 1 * LED
    • 1 * Variable Resistor
    • 1 * Power Supply and Leads
    • Hookup Wires
  • Schematics (http://ima.nyu.sh/interaction-lab/recitation-1-circuits/)
  • Exercise 1

1.The first difficult we meet is we don’t know how to connect the breadboard and the power supply, with the help of a fellow, we figure out this problem.

2. The second problem we have is for switch, first we put it in on half of breadboard, but it doestn’t work.

(wrong way)

3.Than a fellow told us that we should put it in between the two parts, and connect the wires in the diagonal.

4.Finally we finish our first exercise!

Exercise-1

(There is something wrong with the video, I have no ieda of why it happened. I’m really sorry about that)

  • Questions

What’s the circuit inside the switch? Why connecting the diagonal can make it always work?

  • Exercise 2
  1. The first difficult we meet is that we feel confused with the voltage regulator pinout. and we don’t know how to place it, vertically orhorizontally. With the instructions of fellow, we f=made clear that it should be placed like the picture below, or it will cause short circuit.
  2. Then we finish it!

3.Videoexercise-2

  • Exercise 3
  1. First we put all the matrials in the circuit, but we didn’t follow the order provided, than it doesn’t work, so we change the order and it works.

Exercise-3

  • Questions

1.As I learned in Senior high, if it’s a series circuit, than the order won’t influence as long as the LED is in right oder. So I want to know why in exercise 3, the oreder affected the result.

2. We also tried to connect the variable resistor and  buzzer, but the buzzer won’t work unless the resistor is very small, is it because the resistor is too big caused the current is too small for the resistor?

Video