Etsi

Janic YHC

How about a less bloated life that works

Kuukausi

helmikuu 2013

Finger rock! The miniproject of arduino

Prototyypin rakentaminen-course Has given us many thoughts and ideas about what we could create.

Well we were given this task to built our own mini project. But alone we didnt have that much sensors and servos so we decided to do it as a teamwork. As a team there was me,Miika and Teemu. We tried to use our sensors ultrasonic hc-sr04 ,ultrasonic hc-sr05 ,laser?,and a servo to create a something nasty.

We tried to built a machine that would point into 3 different directions. Depending on how close someone tries to come near the object. Well we didnt have anything fancy but the laser but it should have being cool enough.

If trying to make something useful with this idea I think a video camera that would stare at anything that goes near should be cool enough.

So we started connecting those sensors by using breadboard to connect all and in the same time we wrote the details to word document so it wouldnt be hard to get on track by looking on that complicated looking connection.And after all the connections were done and the codes too.Image

Well it didnt work as we thought.

On the left ultrasonic voice sensor had reaction and by trying to see details from (serial monitor in the arduino program) It seemed that everything was working too slowly. And also we thought there was a problem with having only 5v electricity so we used two arduino. But it didnt work. And we had no clue why it didnt work. we checked the code many times and the connections. But then we quit.

We then tried to use only two ultrasonic voice sensors which was a fail too. Then switched into one.

So nothing really worked until we only used one ultrasonic voice sensor and the servo.

And we built this FINGER ROCK  device. It rocks cos it points to different directions.

 

And the code is here.

#include <Servo.h>

const int echoPin = 3;
const int trigPin = 2;

Servo myServo;

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

myServo.attach(4);
myServo.write(90);

pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);

}

void loop()
{
int duration, distance;
digitalWrite(trigPin, HIGH);
delayMicroseconds(100);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = (duration/2) / 29.1;

if(distance > 10 && distance < 150) {
myServo.write(distance);
}

Serial.println(distance);
delay(50);
}

Mainokset

Läksy 3: syvemmälle sensoreihin

Aluksi piti tehdä ryhmätyönä näitä hommia, mutta onneksi Tero(opettaja) sai lisää arduinoja ja pääsin itsekin testailee näitä.Arduinon boardin nimi oli Leonardo ja tä

Liittäminen oli suht helppoa, koska sensorissa luki suht selkeesti asiat.
Mutta tuli pieniä ongelmia johon en osannut selittää, kuten miksi alussa laite ei vastannut vaan piti säätää yms. Lopulta se lähti käyntiin samoilla asetuksilla. Ylipäätään oli mukavaa että arduinot ei toiminut kotona olevilla koneilla. Onneksi koulussa asennettuani Xubuntun peli alkoi vähitellen skulaamaan.

#define trigPin 12
#define echoPin 13

void setup() {
Serial.begin (9600);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
}

void loop() {
int duration, distance;
digitalWrite(trigPin, HIGH);
delayMicroseconds(1000);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = (duration/2) / 29.1;
if (distance >= 200 || distance <= 0){
Serial.println(”Oot liian kaukana”);
}
else {
Serial.print(distance);
Serial.println(” sentteinä”);
}
delay(500);
}

http://trollmaker.com/article3/arduino-and-hc-sr04-ultrasonic-sensor Koodit ja esimerkit sain tuolta sivulta

Image

Laite suostui toimii, pitkän kokeilun jälkeen. alkoi laskee etäisyyksiä, esim kuinka kaukana jokin objekti oli siitä ultraäänietäisyys sensorista. Tykkään tästä sensorista aika paljon.

Toinen sensori oli sit semmoinen, etten tiedä yhtään mikä se on. (waiting for update)

Luo ilmainen kotisivu tai blogi osoitteessa WordPress.com.

Ylös ↑

Mine mood goes up and down

The smooth way I flow and knowing where to go.

Janic YHC

How about a less bloated life that works