Posts with «ultrasonic» label

Controlling a Quadcopter with Gestures

[grassjelly] has been hard at work building a wearable device that uses gestures to control quadcopter motion. The goal of the project is to design a controller that allows the user to intuitively control the motion of a quadcopter. Based on the demonstration video below, we’d say they hit the nail on the head. The controller runs off an Arduino Pro Mini-5v powered by two small coin cell batteries. It contains an accelerometer and an ultrasonic distance sensor.

The controller allows the quadcopter to mimic the orientation of the user’s hand. The user holds their hand out in front of them, parallel to the floor. When the hand is tilted in any direction, the quadcopter copies the motion and will tilt the same way. The amount of pitch and roll is limited by software, likely preventing the user from over-correcting and crashing the machine. The user can also raise or lower their hand to control the altitude of the copter.

[grassjelly] has made all of the code and schematics available via github.


Filed under: Arduino Hacks, drone hacks

New Project: Ultrasonic Spider-Sense

Using an ultrasonic range sensor we can sense how far away objects are.

Read more on MAKE

Object Avoidance Robot MK1

Primary image

What does it do?

Navigate around via ultrasound

Hello everyone. My ultrasonic sensors arrived (4 in total) but instead of using them on my scrapbot, i found some 360 degree servos that i had gathering dust from a previous project.so i decided to make use if them. The scrapbot was too loud because of the build materials so i settled with this. 

In the video it has the distance set to 30cm. 

Materials:

Body: Tamiya universal board (leftover from an onld tank project)

Cost to build

$35,00

Embedded video

Finished project

Complete

Number

Time to build

5 hours

Type

wheels

URL to more information

Weight

1000 grams

read more

BubbleBot

Primary image

What does it do?

Navigates via Ultrasound, annoys the dogs

This is the most complete robot I've ever made.  That's because I intentionally killed it right after I made the video:

I was so sick of this thing that I did what anyone would do: I stuck an X-acto knife in his head.

BubbleBot started life as an RC Car:

Cost to build

$45,00

Embedded video

Finished project

Number

Time to build

Type

URL to more information

Weight

read more

HC-SR04 Ultrasonic Sensor


Introduction:

The HC-SR04 Ultrasonic Sensor is a very affordable proximity/distance sensor that has been used mainly for object avoidance in various robotics projects . It essentially gives your Arduino eyes / spacial awareness and can prevent your robot from crashing or falling off a table. It has also been used in turret applications, water level sensing, and even as a parking sensor. This simple project will use the HC-SR04 sensor with an Arduino and a Processing sketch to provide a neat little interactive display on your computer screen.



Parts Required:
Freetronics Eleven or any compatible Arduino.
HC-SR04 Ultrasonic Sensor
Mini Breadboard 4.5cm x 3.5cm
Protoshieldand female header pins (not essential - but makes it more tidy)
Wiresto connect it all together




The Video:




The Arduino Sketch:



     The above sketch was created using Fritzing.





Arduino Code:
You can download the Arduino IDE from this site.

 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
HC-SR04 Ping distance sensor:
VCC to arduino 5v
GND to arduino GND
Echo to Arduino pin 7
Trig to Arduino pin 8

This sketch originates from Virtualmix: http://goo.gl/kJ8Gl
Has been modified by Winkle ink here: http://winkleink.blogspot.com.au/2012/05/arduino-hc-sr04-ultrasonic-distance.html
And modified further by ScottC here: http://arduinobasics.blogspot.com.au/2012/11/arduinobasics-hc-sr04-ultrasonic-sensor.html
on 10 Nov 2012.
*/


#define echoPin 7 // Echo Pin
#define trigPin 8 // Trigger Pin
#define LEDPin 13 // Onboard LED

int maximumRange = 200; // Maximum range needed
int minimumRange = 0; // Minimum range needed
long duration, distance; // Duration used to calculate distance

void setup() {
Serial.begin (9600);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(LEDPin, OUTPUT); // Use LED indicator (if required)
}

void loop() {
/* The following trigPin/echoPin cycle is used to determine the
distance of the nearest object by bouncing soundwaves off of it. */
digitalWrite(trigPin, LOW);
delayMicroseconds(2);

digitalWrite(trigPin, HIGH);
delayMicroseconds(10);

digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);

//Calculate the distance (in cm) based on the speed of sound.
distance = duration/58.2;

if (distance >= maximumRange || distance <= minimumRange){
/* Send a negative number to computer and Turn LED ON
to indicate "out of range" */
Serial.println("-1");
digitalWrite(LEDPin, HIGH);
}
else {
/* Send the distance to the computer using Serial protocol, and
turn LED OFF to indicate successful reading. */
Serial.println(distance);
digitalWrite(LEDPin, LOW);
}

//Delay 50ms before next reading.
delay(50);
}

The code above was formatted using hilite.me





Processing Code:
You can download the Processing IDE from this site.

 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/* The following Processing Sketch was created by ScottC on
the 10 Nov 2012 : http://arduinobasics.blogspot.com/

Inspired by this Processing sketch by Daniel Shiffman:
http://processing.org/learning/basics/sinewave.html

*/
import processing.serial.*;


int numOfShapes = 60; // Number of squares to display on screen
int shapeSpeed = 2; // Speed at which the shapes move to new position
// 2 = Fastest, Larger numbers are slower

//Global Variables
Square[] mySquares = new Square[numOfShapes];
int shapeSize, distance;
String comPortString;
Serial myPort;

/* -----------------------Setup ---------------------------*/
void setup(){
size(displayWidth,displayHeight); //Use entire screen size.
smooth(); // draws all shapes with smooth edges.

/* Calculate the size of the squares and initialise the Squares array */
shapeSize = (width/numOfShapes);
for(int i = 0; i<numOfShapes; i++){
mySquares[i]=new Square(int(shapeSize*i),height-40);
}

/*Open the serial port for communication with the Arduino
Make sure the COM port is correct - I am using COM port 8 */
myPort = new Serial(this, "COM8", 9600);
myPort.bufferUntil('\n'); // Trigger a SerialEvent on new line
}

/* ------------------------Draw -----------------------------*/
void draw(){
background(0); //Make the background BLACK
delay(50); //Delay used to refresh screen
drawSquares(); //Draw the pattern of squares
}


/* ---------------------serialEvent ---------------------------*/
void serialEvent(Serial cPort){
comPortString = cPort.readStringUntil('\n');
if(comPortString != null) {
comPortString=trim(comPortString);

/* Use the distance received by the Arduino to modify the y position
of the first square (others will follow). Should match the
code settings on the Arduino. In this case 200 is the maximum
distance expected. The distance is then mapped to a value
between 1 and the height of your screen */
distance = int(map(Integer.parseInt(comPortString),1,200,1,height));
if(distance<0){
/*If computer receives a negative number (-1), then the
sensor is reporting an "out of range" error. Convert all
of these to a distance of 0. */
distance = 0;
}
}
}


/* ---------------------drawSquares ---------------------------*/
void drawSquares(){
int oldY, newY, targetY, redVal, blueVal;

/* Set the Y position of the 1st square based on
sensor value received */
mySquares[0].setY((height-shapeSize)-distance);

/* Update the position and colour of each of the squares */
for(int i = numOfShapes-1; i>0; i--){
/* Use the previous square's position as a target */
targetY=mySquares[i-1].getY();
oldY=mySquares[i].getY();

if(abs(oldY-targetY)<2){
newY=targetY; //This helps to line them up
}else{
//calculate the new position of the square
newY=oldY-((oldY-targetY)/shapeSpeed);
}
//Set the new position of the square
mySquares[i].setY(newY);

/*Calculate the colour of the square based on its
position on the screen */
blueVal = int(map(newY,0,height,0,255));
redVal = 255-blueVal;
fill(redVal,0,blueVal);

/* Draw the square on the screen */
rect(mySquares[i].getX(), mySquares[i].getY(),shapeSize,shapeSize);
}
}

/* ---------------------sketchFullScreen---------------------------*/
// This puts processing into Full Screen Mode
boolean sketchFullScreen() {
return true;
}

/* ---------------------CLASS: Square ---------------------------*/
class Square{
int xPosition, yPosition;

Square(int xPos, int yPos){
xPosition = xPos;
yPosition = yPos;
}

int getX(){
return xPosition;
}

int getY(){
return yPosition;
}

void setY(int yPos){
yPosition = yPos;
}
}

The code above was formatted using hilite.me

 
 



If you like this page, please do me a favour and show your appreciation :

  Visit my ArduinoBasics Google + page.
Follow me on Twitter by looking for ScottC @ArduinoBasics.
Have a look at my videos on my YouTube channel.


 
 

 
 
 



However, if you do not have a google profile...
Feel free to share this page with your friends in any way you see fit.

Bike alert tells drivers to back off

Bicycle commuters are often in a battle with drivers for space on the road. [Hammock Boy] does all of his commuting on two human-powered wheels, and is quite interested in not getting hit by a car. He decided to ply his hobby skills to build a device that helps keep him safe. It’s not just a tail light, it’s a sensor that shines brighter the closer a car is to the back of the bike.

The sensor portion is the ultrasonic range finder seen in the center of the protoboard. Surrounding it is a set of LEDs. Each is individually addressable with the whole package controlled by an Arduino. The sketch measures the distance between the back of the bike and whatever’s behind it. If there’s nothing, one Red led is illuminated. If there is an object, the lights shine brighter, and in different patterns as the distance decreases.

Certainly the next iteration could use a standalone chip without the need for the whole Arduino. This could even work with two battery cells and no voltage regulator. We also think the use of any other color than Red LEDs is suspect but we do love the concept.


Filed under: transportation hacks

YA2WDNSOSBBALABMHAMF (Yet Another 2WD Not So Original Starter Bot But At Least Assembled By My Own Hands As My First) or B4short

Primary image

What does it do?

Navigate around via ultrasound avoiding obstacles

Well, finally I've started to assemble my first go at building an autonomous bot, nothing fancy, nothing original just something to learn the ropes. I'm going for a 2WD design that to me seems to be quite ubiquitous.

As of the moment (May, 17th 2012) basically I've only glued together a couple of DVDs (following generalgeek's sugestion) to use as base, and then also hot-glued a couple of DC motors and a 3rd non-motor wheel to it.

Component-wise I'm only waiting for a couple of transistors to build an H-bridge (as sugested on a Dan M's post).

Cost to build

Embedded video

Finished project

Number

Time to build

Type

wheels

URL to more information

Weight

read more

n/a