![](https://static.wixstatic.com/media/afdc09_6ecc222f58bf432aa16dfb2bbaf433a2f000.jpg/v1/fill/w_1280,h_720,al_c,q_85,enc_avif,quality_auto/afdc09_6ecc222f58bf432aa16dfb2bbaf433a2f000.jpg)
COME FAR INSEGUIRE LE LINEE AL ROBOTTINO, PER ESEMPIO USANDO L'8 NERO IN DOTAZIONE
Per far spostare il robottino sulle linee nere dovrete utilizzare per la scrittura a blocchi il codice qui sotto riportato:
![2-mbot.png](https://static.wixstatic.com/media/afdc09_6fd5339f02d1412d9e8843c18e452194~mv2.png/v1/fill/w_545,h_333,al_c,q_85,usm_0.66_1.00_0.01,enc_avif,quality_auto/2-mbot.png)
Invece per far spostare il robottino sulle linee nere dovrete utilizzare per la scrittura in arduino il codice qui sotto riportato:
// generated by mBlock5 for mBot
// codes make you happy
#include <MeMCore.h>
#include <Arduino.h>
#include <Wire.h>
#include <SoftwareSerial.h>
MeLineFollower linefollower_2(2);
MeDCMotor motor_9(9);
MeDCMotor motor_10(10);
void move(int direction, int speed) {
int leftSpeed = 0;
int rightSpeed = 0;
if(direction == 1) {
leftSpeed = speed;
rightSpeed = speed;
} else if(direction == 2) {
leftSpeed = -speed;
rightSpeed = -speed;
} else if(direction == 3) {
leftSpeed = -speed;
rightSpeed = speed;
} else if(direction == 4) {
leftSpeed = speed;
rightSpeed = -speed;
}
motor_9.run((9) == M1 ? -(leftSpeed) : (leftSpeed));
motor_10.run((10) == M1 ? -(rightSpeed) : (rightSpeed));
}
void _delay(float seconds) {
long endTime = millis() + seconds * 1000;
while(millis() < endTime) _loop();
}
void setup() {
while(1) {
if((0 ? (3 == 0 ? linefollower_2.readSensors() == 0 :
(linefollower_2.readSensors() & 3) == 3) :
(3 == 0 ? linefollower_2.readSensors() == 3 :
(linefollower_2.readSensors() & 3) == 0))){
move(1, 50 / 100.0 * 255);
}else{
if((1 ? (2 == 0 ? linefollower_2.readSensors() == 0 :
(linefollower_2.readSensors() & 2) == 2) :
(2 == 0 ? linefollower_2.readSensors() == 3 :
(linefollower_2.readSensors() & 2) == 0))){
move(4, 50 / 100.0 * 255);
}else{
if((1 ? (1 == 0 ? linefollower_2.readSensors() == 0 :
(linefollower_2.readSensors() & 1) == 1) :
(1 == 0 ? linefollower_2.readSensors() == 3 :
(linefollower_2.readSensors() & 1) == 0))){
move(3, 50 / 100.0 * 255);
}
}
}
_loop();
}
}
void _loop() {
}
void loop() {
_loop();
}