Ugh, I need a better hobby. Ryan Mitchell made this project: https://hackaday.io/project/12019-search-for-a-four-servo-walking-robot, and i instantly fell in love. I built one, looked at it, and asked myself what I was doing with my life. My misery is perpetual, of course, so now i'm adding sensors. Right now the only one I could find was a ultrasonic srf04, so here we go...
There's not really much to put here, mainly because it's so simple. Literally ryan's build, with a SRF04 hot glued on the front, wired up to the nano. It's just the code that's going to be a bitch. I haven't tried turning it, only going forwards and backwards, so that'll be fun.
I'm pretty proud of this one- I was ONE jumper wire short. i needed a female to male one, but i couldn't find it, so i soldered a wire to the end of a single female header, and covered it with heat shrink.
One more thing, i have a newfound hate for those cheap little servos. I think i've had to replace two, just because the gears wear down or something. Maybe i should cnc some metal ones...
I suck at coding, so thanks to this project: #Bracelet Dodges Obstacles, i'll be using that to base my code off of:
#define echo 8#define trig 7long duration,distance;
voidsetup(){
Serial.begin(9600);
pinMode(echo,INPUT);
pinMode(trig,OUTPUT);
pinMode(5,OUTPUT);
}
voidloop(){
digitalWrite(trig,LOW);
delayMicroseconds(2);
digitalWrite(trig,HIGH);
delayMicroseconds(10);
digitalWrite(trig,LOW);
duration=pulseIn(echo,HIGH);
distance=(duration/(2*29));
if(distance>=500 || distance<=0){
Serial.println("____");
}
else{
Serial.print(distance);
Serial.println("cm.");
digitalWrite(5,LOW);
}
if(distance<=45 && distance>=1){// distance in which the bracelet vibrates, you can edit according to your need
digitalWrite(5,HIGH);
Serial.println("Alarm!!!");
}
delay(400);
}