Interaction Lab Recitation 02

Peter Wang

Marcela Godoy

INTM-SHU  101 002

8 February 2018

W2 Documentation for Lab 6

Materials

  • 1 * Arduino Kit and its contents, including:
  • 1 * Breadboard
  • 1 * Arduino Uno
  • 1 * Buzzer
  • 1 * Push-Button Switch
  • 1 * LDR
  • 220 ohm Resistors
  • LEDs
  • 10K ohm Variable Resistors (Potentiometers)
  • 1 * USB A to B Cable
  • Jumper Cables (Hook-up Wires)

Part.a

Step 1

We just followed the schematic plot and refered to the example in arduino IDE to get the code.

It worked well.

Step 2

Minor change in the code: changing the part that lits the LED into one that makes the LED blink once so that the loop function will do the rest of the work for me (BLINKING!)

 

Step 3

Even easier: just use the exact same code as that used in step 1 but switch the position of HIGH and LOW.

 

Step 4

I built several simple circuits and used the power of programing to achieve the following effect:

Voila~!

Here is the schematic plot of this circuit:

Simple & repetitive work…

 

Part.b

Step 1

Again, we followed schematic plot provided but this time it didn’t work as expected as we didn’t know how to connect the potentiometer as shown below:

then we looked it up on the internet and figured the right way to make it work and here is the result:

 

Step 2

Similar to what’s done in step 1 but with more potentiometers and LEDs!

Done~!

 

Reflection Questions:

1. In terms of input and output, I would say that the camera is a kind of input as it captures visual image, and the street lights as an output as it receive signal from its control center and emit light correspondingly.

2. Oh boy. if I had that many of LEDs, I would like to see each of them as a pixel as one on the monitor so that possibly I can use the whole thing as a monitor.

3. In computing, the only two things that matter are input or output (and they can come in various forms and values). This is why the computer sees us as having only one eye: because there is one visual output (a.k.a. the monitor) that we can receive image from the computer. However, this situation is changing right now as VR

 

 

 

Individual

Step 1

const int buttonPin = 4;
const int ledPin = 11;
int buttonstate = 0;

void setup() {
	pinMode(ledPin, OUTPUT);
	pinMode(buttonPin, INPUT);
	Serial.begin(9600);
}

void loop() {
	buttonstate = digitalRead(buttonPin);
	if (buttonstate == HIGH) {
		digitalWrite(ledPin, HIGH);
	} else {
		digitalWrite(ledPin, LOW);
	}
	Serial.print(buttonstate);

delay(2);
}



Step 2

const int buttonPin = 4;
const int ledPin = 11;
int buttonstate = 0;

void setup() {
	pinMode(ledPin, OUTPUT);
	pinMode(buttonPin, INPUT);
	Serial.begin(9600);
}

void loop() {
	buttonstate = digitalRead(buttonPin);
	if (buttonstate == HIGH) {
digitalWrite(ledPin, HIGH);
			delay(100);
			digitalWrite(ledPin, LOW);
			delay(100);
		}
	} else {
		digitalWrite(ledPin, LOW);
	}
	Serial.print(buttonstate);

delay(300);
}




Step 3

const int buttonPin = 4;
const int ledPin = 11;
int buttonstate = 0;

void setup() {
	pinMode(ledPin, OUTPUT);
	pinMode(buttonPin, INPUT);
	Serial.begin(9600);
}

void loop() {
	buttonstate = digitalRead(buttonPin);
	if (buttonstate == HIGH) {
		digitalWrite(ledPin, LOW);
	} else {
		digitalWrite(ledPin, HIGH);
	}
	Serial.print(buttonstate);

delay(2);
}




Step 4

void setup() {
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
}

void loop() {
digitalWrite(2, HIGH);
delay(100);
digitalWrite(2, LOW);

digitalWrite(3, HIGH);
delay(100);
digitalWrite(3, LOW);

digitalWrite(4, HIGH);
delay(100);
digitalWrite(4, LOW);

digitalWrite(5, HIGH);
delay(100);
digitalWrite(5, LOW);

digitalWrite(6, HIGH);
delay(100);
digitalWrite(6, LOW);

digitalWrite(7, HIGH);
delay(100);
digitalWrite(7, LOW);

digitalWrite(8, HIGH);
delay(100);
digitalWrite(8, LOW);

digitalWrite(9, HIGH);
delay(100);
digitalWrite(9, LOW);
}






Pair 

step 1

const int potPin = A0;
const int ledPin = 11;

int sen = 0;
int out = 0;

void setup() {
pinMode(ledPin, OUTPUT);
}

void loop() {
sen = analogRead(potPin);
out = map(sen, 0, 1023, 0, 255);
analogWrite(ledPin, out);
delay(2);
}




Step 2

int sen1 = 0;
int sen2 = 0;
int sen3 = 0;

const int ledPin1 = 9;
const int ledPin2 = 10;
const int ledPin3 = 11;

int out1 = 0;
int out2 = 0;
int out3 = 0;


void setup() {
Serial.begin(9600);
}

void loop() {
sen1 = analogRead(A1);
sen2 = analogRead(A2);
sen3 = analogRead(A3);

out1 = map(sen1, 0, 1023, 0, 255);
out2 = map(sen2, 0, 1023, 0, 255);
out3 = map(sen3, 0, 1023, 0, 255);

analogWrite(ledPin1, out1);
analogWrite(ledPin2, out2);
analogWrite(ledPin3, out3);

Serial.print(sen3);
Serial.print("  ");

delay(2);
}



One thought on “Interaction Lab Recitation 02

Leave a Reply