void stop() { DigitalWrite(D4, false); DigitalWrite(D2, false); DigitalWrite(D5, false); DigitalWrite(D7, false); AnalogWrite(PWM3, 0); AnalogWrite(PWM6, 0); }
void right(int speed) { DigitalWrite(D4, false); DigitalWrite(D2, false); DigitalWrite(D5, true); DigitalWrite(D7, false); AnalogWrite(PWM3, speed); AnalogWrite(PWM6, speed); }
void forward(int speed) { DigitalWrite(D4, false); DigitalWrite(D2, true); DigitalWrite(D5, false); DigitalWrite(D7, true); AnalogWrite(PWM3, speed); AnalogWrite(PWM6, speed); }
void backward(int speed) { DigitalWrite(D4, true); DigitalWrite(D2, false); DigitalWrite(D5, true); DigitalWrite(D7, false); AnalogWrite(PWM3, speed); AnalogWrite(PWM6, speed); }
void setup() { initBoard(); while(true) { AnalogWrite(PWM9, Random()); AnalogWrite(PWM10, Random()); AnalogWrite(PWM11, Random()); delay(300); } }
void setup() { initBoard(); float x = 0; float y = 0; while(true) { y = abs((sin(x)*100)); AnalogWrite(PWM9, y); x = (x+0.01); delay(10); } }
void setup() { initBoard(); float senValue = 0; while(true) { senValue = AnalogRead(sensor0); if((senValue<33)) { AnalogWrite(PWM9, senValue); AnalogWrite(PWM10, 0); AnalogWrite(PWM11, 0); } else { if((senValue<66)) { AnalogWrite(PWM9, 0); AnalogWrite(PWM10, senValue); AnalogWrite(PWM11, 0); } else { AnalogWrite(PWM9, 0); AnalogWrite(PWM10, 0); AnalogWrite(PWM11, senValue); } } delay(300); } }