Lab2_NJ


1. a) Upon changing the pin number to 11 in the 2 digitalWrite lines, the LED started blinking softly. Upon changing the number in the pinMode line, the LED flashed brighter.

The explanation for the requirement of the correct pinMode line is copied here from the Arduino foundations page:

 

"Pullup Resistors

Often it is useful to steer an input pin to a known state if no input is present. This can be done by adding a pullup resistor (to +5V), or a pulldown resistor (resistor to ground) on the input, with 10K being a common value.

There are also convenient 20K pullup resistors built into the Atmega chip that can be accessed from software. These built-in pullup resistors are accessed in the following manner.

pinMode(pin, INPUT);           // set pin to input
digitalWrite(pin, HIGH);       // turn on pullup resistors

Note that the pullup resistors provide enough current to dimly light an LED connected to a pin that has been configured as an input. If LED's in a project seem to be working, but very dimly, this is likely what is going on, and the programmer has forgotten to use pinMode() to set the pins to outputs."

 

b) The delays can be increased to decrease the rate of blinking.

 c) A resistor would be added to protect the board and LED from high voltages.

2. a) buttonPin=2; ledPin=9;

b)

/*
  Button
 
 Turns on and off a light emitting diode(LED) connected to digital 
 pin 13, when pressing a pushbutton attached to pin 2.
 
 
 The circuit:
 * LED attached from pin 13 to ground
 * pushbutton attached to pin 2 from +5V
 * 10K resistor attached to pin 2 from ground
 
 * Note: on most Arduinos there is already an LED on the board
 attached to pin 13.
 
 
 created 2005
 by DojoDave <http://www.0j0.org>
 modified 30 Aug 2011
 by Tom Igoe
 
 This example code is in the public domain.
 
 http://www.arduino.cc/en/Tutorial/Button
 */

// constants won't change. They're used here to
// set pin numbers:
const int buttonPin = 2;     // the number of the pushbutton pin
const int ledPin =  9;      // the number of the LED pin
  // Pin 13: Arduino has an LED connected on pin 13
  // Pin 11: Teensy 2.0 has the LED on pin 11
  // Pin 6: Teensy++ 2.0 has the LED on pin 6

// variables will change:
int buttonState = 0;         // variable for reading the pushbutton status

void setup() {
  // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);     
  // initialize the pushbutton pin as an input:
  pinMode(buttonPin, INPUT);    
}

void loop(){
  // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);

  // check if the pushbutton is pressed.
  // if it is, the buttonState is HIGH:
  if (buttonState == LOW) {    
    // turn LED on:   
    digitalWrite(ledPin, HIGH); 
  }
  else {
    // turn LED off:
    digitalWrite(ledPin, LOW);
  }
}

3. a) No line had to be modified

b) By changing the step size in the for loop. Also, increase in delay would increase time between the two series of increasing and decreasing brightness.

c) Traverse an array that contains voltage values that cause linear changes in brightness, as perceived by the human eye.

 

e.g. V1 (first element of array) causes brightness B1 as perceived by the human eye. V2 causes B2. V3 causes B3. V1, V2 and V3 are chosen so that (B2-B1)/B1 = (B3-B2)/B2 

✔ Did you try implementing the code to do this?

4. a) The power supply used for the LED was about 4V. This gives a min resistance of 27 Ohms. A resistor of 47 Ohm was used for safety.

  2.

 

Schematic uploaded as PPT file (see my folder)

 

a) Yes. DSP performs very rapid computations to track motion from images being captured by the sensing array.

b) Yes. Probably a CMOS sensing array. The voltage relayed from each pixel of the array is proportional to the light intensity the pixel sees. The sensed information is just a bunch of voltage signals which can be processed to obtain the object image. The voltage signals may be digitized as soon as they are acquired or inside the DSP.

c) From the PC according to the USB protocol (around 5 V). Nothing physically visible suggests transformation/regulation of power though resistors may be used in voltage divider kind of circuits. Voltages vary throughout the system. For example, the point from the device that was taken to power our LED had a voltage of 4V relative to the ground of the power supply.

d) Depends on how information is defined here. Computations are being performed and data would be constantly stored for use in these computations. As an external memory is not visible, it is likely that most data is stored in registers (which have a defined bit size to tell the size of the variable that they can store) included in the microcontroller/DSP. Beyond computations, the need for storing data is limited as information can continuously be transmitted to the PC.

4. Video posted as separate file in my folder