Showing posts with label object. Show all posts
Showing posts with label object. Show all posts

Potentiometer

Arduino Code

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

void loop(){
Serial.print("Value: ");
Serial.print(analogRead(0));
delay(100);
}

L293DNE Dual H-Bridge


Supplier (Jameco)
Datasheet

PNP Transistor

NPN Transistor

Emitter Base Collector

ping))) Ultrasonic Sensor




const int pingPin = 7;

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

void loop(){
  long duration, inches, cm;

  pinMode(pingPin, OUTPUT);
  digitalWrite(pingPin, LOW);
  delayMicroseconds(2);
  digitalWrite(pingPin, HIGH);
  delayMicroseconds(5);
  digitalWrite(pingPin, LOW);
  pinMode(pingPin, INPUT);
  duration = pulseIn(pingPin, HIGH);
  inches = microsecondsToInches(duration);
  cm = microsecondsToCentimeters(duration);
  
  Serial.print(inches);
  Serial.print("in, ");
  Serial.print(cm);
  Serial.print("cm");
  Serial.println();
  
  delay(100);
}

long microsecondsToInches(long microseconds){
  return microseconds / 74 / 2;
}

long microsecondsToCentimeters(long microseconds){
  return microseconds / 29 / 2;
}


Supplier (Jameco)

47Ω Resistor

Supplier (Maplin)

3V DPDT Relay

Supplier (Radio Shack)

7-Segment LED

LED (Light Emitting Diode)

Jumper Wires

Supplier (Sparkfun)

Diode

Electricity can pass from silver to black, but not black to silver.

Breadboard

Supplier (Carnegie Mellon University's Fun With Robots Club)

The input pins on a breadboard are connected row-wise, divided by the gutter; i.e. 1A-1E are connected.

The power pins are connected column wise: canonically the blue column is ground and the red, source.

AA Battery Holder