Scoala de vara_idg_introducere_in_robotica

Post on 14-May-2015

157 views 2 download

Tags:

Transcript of Scoala de vara_idg_introducere_in_robotica

Introducere in Robotica

ROBOT

MOTOARESENZORI

PROCESOR

Motoare

Senzori

Procesor

ROBOTI(2-3 exemple)

CUM ?

Procesor

Motoare [1]

Pololu

Motoare [2]

Motoare [3]

Driver - L298 DIY

Motoare [cod]

Senzori [1]

Sharp Infrared

Senzori [cod]

Robot

Test senzori

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

int readDistance() { int sum = 0; for (int i=0; i<6;i++){ float volts = analogRead(0)* ((float) 5 / 1024); float distance = 65*pow(volts, -1.10); sum = sum + distance; delay(5); } return (int)(sum / 6);}

void loop() { int distance = readDistance(); Serial.println(distance);}

Test senzori

Test motoare

int MOTOR1_PIN1 = 10;int MOTOR1_PIN2 = 11;

int MOTOR2_PIN1 = 5;int MOTOR2_PIN2 = 6;

void setup() { pinMode(11, OUTPUT); pinMode(10, OUTPUT); pinMode(6, OUTPUT); pinMode(5, OUTPUT); Serial.begin(9600);}

void loop() { go (255, 255); }

Test motoarevoid go(int speedLeft, int speedRight) { if (speedLeft > 0) { analogWrite(MOTOR1_PIN1, speedLeft); analogWrite(MOTOR1_PIN2, 0); } else { analogWrite(MOTOR1_PIN1, 0); analogWrite(MOTOR1_PIN2, -speedLeft); }

if (speedRight > 0) { analogWrite(MOTOR2_PIN1, speedRight); analogWrite(MOTOR2_PIN2, 0); } else { analogWrite(MOTOR2_PIN1, 0); analogWrite(MOTOR2_PIN2, -speedRight); }}

Obstacole !

(fiecare echipa individual)

SUMO !