Introduction: Servocar

johdanto:

Servocar on arduinon avulla toimiva liikkuva ja esteitä väistelevä
ajoneuvo. Se liikkuu kahden servomoottorin voimalla. Servomoottoreihin on liitetty pyörät, joihin on laitettu teippiä päälle pitoa antamaan. Esteiden väistely onnistuu analogisella etäisyyssensorilla. Sensori havaitsee esteen puolen metrin päästä. Esteen havaittaessa renkaat lähtevät pyörimään toisiin suuntiin, jolloin auto kääntyy ja jatkaa liikettään. Se on helppo tehdä.

Step 1: Tarvittavat Osat:

1. Arduino

2. 2 kpl servomoottoria

3. 1 kpl analoginen etäisyyssensori

4. 1 kpl 9v patteri

5. sähköjohtoja

6. 1 kpl koekytkentälevy

7. teippiä

8. pahvia

9. 1 kpl USB 2.0 kaapeli A-UROS/B-UROS

Step 2: Ohjelmointi

#include
int _ABVAR_1_speedleft = 0 ; int _ABVAR_2_speedright = 0 ; int _ABVAR_3_speedright2 = 0 ; Servo servo_pin_9; Servo servo_pin_10;

void setup() { servo_pin_9.attach(9); servo_pin_10.attach(10); }

void loop() { _ABVAR_1_speedleft = 180 ; _ABVAR_2_speedright = analogRead(2) ; if (( ( _ABVAR_2_speedright ) > ( 220 ) )) { _ABVAR_3_speedright2 = 180 ; } else { _ABVAR_3_speedright2 = 0 ; } servo_pin_9.write( _ABVAR_1_speedleft ); servo_pin_10.write( _ABVAR_3_speedright2 ); }