Showing posts with label electromechanics. Show all posts
Showing posts with label electromechanics. Show all posts

Slip Ring Assembly

Parallax ping))) Ultrasonic Sensor
Desoldering Braid
Pololu Pulleys
Copper Clamps
Jumper Wires
12V Unipolar Stepper Motor

Arduino + Tiny Vibrate Motor + Pushbutton





Arduino Code
int buttonPin = 3;
int buttonState = 0;

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

void loop(){
  buttonState = digitalRead(buttonPin);
  switch(buttonState){
    case HIGH:
      Serial.println("off");
      break;
    case LOW:
      Serial.println("on");
      analogWrite(9, 123);
      delay(100);
      analogWrite(9,0);
      break;
  }
  delay(100);
}

2.2kΩ Resistor

Arduino + Pushbutton


Arduino Code

int buttonPin = 3;
int buttonState = 0;

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

void loop(){
buttonState = digitalRead(buttonPin);
switch(buttonState){
case HIGH:
Serial.println("off");
break;
case LOW:
Serial.println("on");
break;
}
delay(100);
}

Arduino + Unipolar Stepper Motor + ULN2004A + Bipolar Stepper Motor + L293DNE + 2 Potentiometers


Arduino Code

#include <Stepper.h>
#define biSTEPS 200
#define uniSTEPS 400
int last_verti, curr_verti, last_horiz, curr_horiz;

Stepper bi_stepper(biSTEPS, 7, 6, 5, 4);
Stepper uni_stepper(uniSTEPS, 8, 9, 10, 11);

void setup(){
Serial.begin(9600);
bi_stepper.setSpeed(15);
uni_stepper.setSpeed(15);
}

void loop(){
sweepVertical();
sweepHorizontal();
}

void sweepVertical(){
bi_stepper.step(10);
bi_stepper.step(-10);
delay(100);
}

void sweepHorizontal(){
uni_stepper.step(20);
uni_stepper.step(-20);
delay(100);
}

void controlVertical(){
curr_verti = analogRead(0);
if(abs(curr_verti - last_verti) > 20) blinkLed();
else bi_stepper.step(curr_verti-last_verti);
last_verti = curr_verti;
delay(100);
}

void controlHorizontal(){
curr_horiz = analogRead(1);
if(abs(curr_horiz - last_horiz) > 20) blinkLed();
else uni_stepper.step(curr_horiz-last_horiz);
last_horiz = curr_horiz;
delay(100);
}

void blinkLed(){
digitalWrite(13, HIGH);
delay(100);
digitalWrite(13, LOW);
}

Resistor

Req = Equivalent Resistance

In Series
Req = R1 + R2 + R3 + ...

In Parallel
1/Req = 1/R1 + 1/R2 + 1/R3 + ...

BlackBrownRedOrangeYellowGreenBlueVioletGreyWhite
0123456789

(ex. Brown Black Red = 1000 = 1KΩ)

Ohm's & Joule's Laws

V = Electric Potential Difference (Volts)
I = Current (Ampere)
R = Resistance (Ohms)
P = Power (Watts)


V = I/R
P = IV
P = V2/R
P = I2/R

Potentiometer

Arduino Code

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

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

Arduino + Unipolar Stepper Motor




Arduino Code (Back & Forth)

#include <Stepper.h>
#define STEPS 400 //360° divided by step angle

Stepper stepper(STEPS, 8, 9);

void setup(){
stepper.setSpeed(30); //RPMs
}

void loop(){
stepper.step(100);
delay(100);
stepper.step(-100);
delay(100);
}


Arduino Code (Back & Forth)

#include <Stepper.h>
#define STEPS 400 //360° divided by step angle
Stepper stepper(STEPS, 8, 9, 10, 11);

void setup(){
stepper.setSpeed(30); //RPMs
}

void loop(){
stepper.step(100);
delay(100);
stepper.step(-100);
delay(100);
}

Arduino + Bipolar Stepper Motor





Arduino Code (Back & Forth)


#include <Stepper.h>
#define STEPS 200 //360° divided by step angle
Stepper stepper(STEPS, 9, 10, 11, 12);

void setup(){
stepper.setSpeed(30); //RPMs
}

void loop(){
stepper.step(100);
delay(100);
stepper.step(-100);
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)