menu alto

  • PUBBLICITA’ CONTATTI
Modellismo HobbyMedia Modellismo HobbyMedia News di Modellismo dinamico e statico
Home

Navigazione

  • NEWS DI MODELLISMO
  • TAMIYA
  • TRAXXAS
  • LEGO
  • COMPETIZIONI
  • PISTE RC
  • EDICOLA
Return to Content


Easy Arduino Robot – Modellismo e robotica amatoriale

07 Lug 2009

Di Frankie - arduino, Robot

ArduinoFan, un utente del sito Let’s Make Robots ha postato un progetto per realizzare un semplice quanto divertente robot utilizzando la scheda Arduino.  Si può vedere come il telaio del robot si basa su una basetta breadboard su cui sono attaccati i servi, l’Arduino e le altre parti tramite edel nastro biadesivo spesso (con supporto in schiuma acrilica) e delle fascette autobloccanti di plastica. OK, no nsarà come Wall-e ma ci sembra un ottimo progetto per i modellistici che vogliono avvicinarsi alla robotica e all’utilizzo di Arduino.

Puoi trovare le informazioni per il montaggio qui.

Materiali utilizzati:
(1) Arduino
(2) Continuous Rotation Servos
(1) Standard Servo
(1) Box per 4 batterie AA
(4) AA Batterie
(1) 1-1/4″ Caster Wheel
(2) Servo Mountable Wheels
(1) Sharp IR Sensor
(1) IR Sensor Servo Mount
(1) Breadboard da 840 contatti
Filo elettrico
Fascette autobloccanti
Nastro biadesivo

100_0889

Ecco il coide da caricare su Arduino per gestire i servi.

Shawn – http://www.ArduinoFun.com
Arduino Sketch:
/*
* Brian Bailey *
* Drives servo robot and avoids obsticles using Sharp IR range finder
* http://bunedoggle.com/robots.php
*/

#define CENTER 1400
#define CENTER_R CENTER
#define CENTER_L CENTER+1

#define LEFT CENTER-650
#define RIGHT CENTER+650

#define R_FULL_FORWARD R_STOP+300
#define L_FULL_FORWARD L_STOP-300
#define L_FULL_REVERSE R_FULL_FORWARD
#define R_FULL_REVERSE L_FULL_FORWARD
#define R_STOP 1450
#define L_STOP 1450

#define LEFT_TURN 0
#define RIGHT_TURN 1
#define QUARTER_TURN_DELAY 800 // in milliseconds

#define DIST_ERR 50

#define RSPEED R_STOP + 100
#define LSPEED L_STOP – 110

#define DEBUG 0

#define BUMP_DELAY 125

int leftDist = 0; // the average
int rightDist = 0;
int forDist = 0;
int vision = 5;
boolean goingLeft = true;
boolean turnNow = false;

int curDist = 0;
int objDist = 0;
int objDir = 0;

#include .h>

// create servo objects to control servos
ServoTimer2 leftWheel;
ServoTimer2 rightWheel;
ServoTimer2 head;

int leftSpeed = LSPEED; // variable to store the servo position
int rightSpeed = RSPEED;
int headPos=CENTER;

void setup()
{
leftWheel.attach(10); // attaches the servo on pin 9 to the servo object
rightWheel.attach(11);
head.attach(9);

rightWheel.write(rightSpeed); // Stop Wheels
leftWheel.write(leftSpeed); // Stop Wheels
head.write(headPos);

Serial.begin(9600); // initialize serial communication with computer
}

/*******************************************************
* turn – Executes an in-place turn for miliseconds
* QUARTER_TURN_DELAY gets you about 90 deg
********************************************************/
void turn(int dir, int duration){
// Store previous speeds
//rightSpeed = rightWheel.read();
//leftSpeed = leftWheel.read();

if(dir == LEFT_TURN){
rightWheel.write(R_FULL_REVERSE);
leftWheel.write(L_FULL_FORWARD);
}
else {
rightWheel.write(R_FULL_FORWARD);
leftWheel.write(L_FULL_REVERSE);
}
delay(duration);

// restore previous speeds
rightWheel.write(rightSpeed);
leftWheel.write(leftSpeed);
}

void go(){
rightWheel.write(RSPEED);
leftWheel.write(LSPEED);
}

void stop(){
rightWheel.write(R_STOP);
leftWheel.write(L_STOP);
}

/***************************************************
* scan – This function is called every cycle
* it turns the head a click and records a distance and
* heading. It only saves the closest object info.
* objDist and objDir hold the closest object data
****************************************************/
void scan(){

if(goingLeft){
head.write(head.read()-10);
}
else{
head.write(head.read()+10);
}

if(head.read() <= LEFT){
goingLeft = false;
forDist = 0;
objDist = 0;
turnNow = true;
}

if(head.read() >= RIGHT){
goingLeft = true;
forDist = 0;
objDist = 0;
turnNow = true;
}

curDist = analogRead(vision);
if(curDist > objDist){
objDist = curDist;
objDir = head.read();
if(DEBUG){
Serial.print(”New close obj at Dist: “);
Serial.print(objDist);
Serial.print(” heading: “);
Serial.println(objDir);
}
}

delay(10);

}

/**********************************************************
* bump
* Executes a nudge to a given side
* Pass in LEFT_TURN or RIGHT_TURN
***********************************************************/
void bump(int dir){
#define BUMP 100
if(dir == LEFT_TURN){
rightWheel.write(rightWheel.read()-BUMP);
delay(BUMP_DELAY);
rightWheel.write(rightWheel.read()+BUMP);
}
else {
leftWheel.write(leftWheel.read()+BUMP);
delay(BUMP_DELAY);
leftWheel.write(leftWheel.read()-BUMP);
}
}

/**********************************************************
* bumpSteer
* Nudges us back on coarse if we see something off to the
* side. Relies on objDist and objDir to be updated by scan()
*
***********************************************************/
void bumpSteer(){
// One bump per scan
if(!turnNow || objDist < 470)
return;

if(objDir > CENTER){
bump(RIGHT_TURN);
}
else if(objDir <= CENTER){
bump(LEFT_TURN);
}
// No turn till next scan
turnNow = false;
}

void lookAround(){
head.write(LEFT);
delay(400);
leftDist = analogRead(vision);
head.write(CENTER);
delay(400);
forDist = analogRead(vision);
head.write(RIGHT);
delay(400);
rightDist = analogRead(vision);
head.write(CENTER);
delay(200);
}

int cornerNav(){
if(objDist > 600 && objDir > CENTER – 350 && objDir < CENTER + 200){

if( DEBUG ){
Serial.println(“Check:”);
Serial.println(objDist);
Serial.println(objDir);
}

stop();
lookAround();
if(leftDist > rightDist + DIST_ERR){
turn(LEFT_TURN, QUARTER_TURN_DELAY);
}
else {
turn(RIGHT_TURN, QUARTER_TURN_DELAY);
}
go();
objDist = 0;
return 1;
}
return 0;
}

void loop()
{

scan();
if(!cornerNav()){
bumpSteer();
}

}

CORALLY // Radiosistemi

Un commento su Easy Arduino Robot – Modellismo e robotica amatoriale

  1. barattarli 16 dicembre 2015 at 10:13 #

    Veramente un eccellentepost. Leggo con interesse il blog http://www.hobbymedia.it. Avanti con questa grinta!

    leggi questo articolo

    Rispondi

Lascia un commento Click here to cancel reply.

Articoli che potrebbero interessarti

  • UFO Robot GOLDRAKE torna in edicola con il modellino a fascicoli HachetteUFO Robot GOLDRAKE torna in…
  • RC Racing TV: il modellismo in diretta!RC Racing TV: il modellismo in diretta!
  • Catalogo Modellismo Tamiya 2025Catalogo Modellismo Tamiya 2025
  • Tamiya: YAMAHA FZR500R - Modellismo staticoTamiya: YAMAHA FZR500R -…
  • Video Modellismo: Faster & Tougher With ARRMAVideo Modellismo: Faster &…
  • Edicola: Lamborghini Revuelto in scala 1:8 - Modellismo a fascicoli DeAgostiniEdicola: Lamborghini Revuelto in…
RadiosistemiCarismaElectronic DreamsRadiosistemi

Negozi di modellismo

Jet Model
Casa del Modellismo

Notizie in evidenza:

  • Tamiya alla fiera di Norimberga: Porsche 934 50th Anniversary (1976) - Toy Fair 2026 Tamiya alla fiera di Nori... A Norimberga è iniziata l'edizione 2026 della leggendaria fiera del giocattolo e del modellismo: S...
  • HPI Racing:  Nano-TTR 1987 BMW M3 Warsteiner HPI Racing: Nano-TTR 198... HPI continua a portare novità: sugli scaffali dei negozi di modellismo (o meglio il distributore u...
  • HPI Racing: Falken Porsche 911 GT3 RSR - video HPI Racing: Falken Porsch... Per iniziare l'anno alla grande, la HPI Racing, distribuita in Italia dalla Radiosistemi, ha posta...
  • Tamiya: Porsche 934 Turbo RSR Vaillant 1976 in scala 1/24 Tamiya: Porsche 934 Turbo... Se ami le Porsche e cerchi un kit economico per avvicinarti al modellismo statico, la Tamiya ha an...
  • Tamiya: Quirkhopper, Lunch ox Evo, e Ford F150 Ranger XLT al Toy Fair 2026 Tamiya: Quirkhopper, Lunc... Alla fiera del giocattolo e del modellismo di Norimberga abbiamo potuto ammirare tante novità dell...
  • Vanquish: VS4-10 Origin Classic & Classic Pro Vanquish: VS4-10 Origin C... L'Americana Vanquish Products ha rilasciato due crswler in scala 1/10: Origin Classic e Origin C...
  • Team Associated: RC10 4X4 Pickup Truck kit Team Associated: RC10 4X4... Il truck radiocomandato RC10 4×4 proposto da Team Associated è progettato non solo per il realismo...
  • Pandora RC: RWB 964 Type RAUH-WELT BEGRIFFRWB in scala 1/10 Pandora RC: RWB 964 Type... Il giovane brand Pandora RC ha annunciato che per la fine del mese di novembre, sugli scaffali dei...
LEGO TECHNICS

©2026 Hobby Media

width=
  • NEWS DI MODELLISMO
  • TAMIYA
  • TRAXXAS
  • LEGO
  • COMPETIZIONI
  • PISTE RC
  • EDICOLA
Questo sito utilizza i cookie: Leggi di più.