Micro Servo
Tower Pro SG90 is an ideal servo motor for little mechanism. This one is comonly seen in RC vehicles and I saw it also works with PWM signal.
I have used it before, in a robotic arm project with 5 servos like this with acrylic body. To use the servo in arduino, you have to load the servo.h library at the begining of the code.
Technical Details:
Size: 23.1 mm x 12.2 mm x 29 mm
Working Voltage: 4.8-6v
Weight: 9 g
Speed at 4.8 V: 0.06 - 0.12 sec/60°
Compulsion Torque: 1.3 kg/cm
Torque: 0.06 - 0.12 sec/60°
Cable Lenght: 15 cm
For this project I used a basic code found at https://www.instructables.com/, which: loads the library, declares the servo in pin 5, attaches it to the pin, and then move it to 0º, 90º and 180º positions, with a 1000 millisenconds delay between them.
Servo Servo1;
void setup() {
}
void loop(){
}
Ultrasonic Sensor
This is a ultrasonic sensor that has an emitter (Trigger) and a receiver (Echo) of ultrasonic signal, with which it can measure distances from 2 cm to 400 cm with a precision of 3 mm.
It works by sending a signal from your TRIGGER for a certain time (10ms), this signal bounces off an object and returns, and then the time the signal activates ECHO is measured. This time is then divided or multiplied in an equation related to the speed of sound, according to the desired unit of measurement (cms or inches).
Technical Details:
Dimensions: 45mm x 20mm x 15mm
Working voltage: DC 5V
Current consumption: 15 mA
Operating frequency: 40 Hz
Maximum visual range: 4m
Minimum viewing range: 2 cm
Visual angle: 15 °
Trigger foot input signal: 10 us TTL Pulse
Echo output signal: TTL input signal and distance ratio
For this project I used a basic code found at https://pimylifeup.com/, which basically measures a distance and prints it in the serial monitor.
int trigger_pin = 2;
int echo_pin = 3;
long distance, pulse_duration;
void setup() {
Serial.begin (9600);
pinMode(trigger_pin, OUTPUT);
pinMode(echo_pin, INPUT);
digitalWrite(trigger_pin, LOW);
}
void loop() {
digitalWrite(trigger_pin, HIGH);
delayMicroseconds(10);
digitalWrite(trigger_pin, LOW);
pulse_duration = pulseIn(echo_pin, HIGH);
distance = round(pulse_duration * 0.0171);
Serial.print(distance);
Serial.print("cm");
Serial.println();
delay(500);
}
#define LDR 2
#define Motor 7
#define GREEN 8
float LDRval = 0;
float sunny = 0; // calibrate sensor value WHEN LIGHT
float dark = 1024; // calibrate sensor value WHEN DARK
float treshold = 50; // define treshold to turn lights ON or OFF
#include
SoftwareSerial mySerial(0, 1); // RX, TX (0 y 1)
void setup() {
mySerial.begin(9600);
pinMode(LDR, INPUT);
pinMode(Motor, OUTPUT);
pinMode(GREEN, OUTPUT);
}
digitalWrite(Motor,HIGH);
digitalWrite(GREEN,LOW);
digitalWrite(Motor,LOW);
digitalWrite(GREEN,HIGH);
}
mySerial.print(analogRead(LDR));
mySerial.print(" Light Percent: ");
mySerial.print(LDRval);
mySerial.println(" %");
}
Mobirise free creator - Learn more