Arduino workshopissa rakennettu robotti
Arduino + 2 servoa + itsetehtyjä "viiksikarvoja" for collision detection
Koodi: http://pastebin.com/CyDQc3Wd
Vacubot openscad koodia:
http://kirjoitusalusta.fi/hacklab-vacubot
DCMOOTTORI << >>
void setup() {
digitalWrite(13, LOW); // Nothing works until...
pinMode(13, OUTPUT);
pinMode(9, OUTPUT); // Moottori <<
pinMode(3, OUTPUT); // Moottori >>
Serial.begin(115200); // Avataan portti
}
void loop() {
while(!Serial.available() ){/* sleep */};
digitalWrite(13,HIGH);
int c = Serial.read();
if(c>='0' && c<='9') {
int n = c -'0'; // n saa arvoja 0-9
int v = (n*255)/9; // v saa arvoja 0-255
analogWrite(9, v);
Serial.print(v);
}
Serial.print(" ");
c = Serial.read();
if(c>='0' && c<='9') {
int n = c -'0'; // n saa arvoja 0-9
int v = (n*255)/9;
analogWrite(3, v);
Serial.println(v);
}
}