Arduino {code}racer API
... better know the details.
Lower level fun stuff methods

Functions

void CodeRacer::look_around ()
 Fun stuff - will move the servo around after a random amount of time. More...
 
void CodeRacer::kitt ()
 Fun stuff - you know Knightrider... More...
 

Detailed Description

Function Documentation

◆ look_around()

void CodeRacer::look_around ( )

Fun stuff - will move the servo around after a random amount of time.

Returns
nothing

Definition at line 440 of file CodeRacer.cpp.

441 {
442  if (_servo_look_around_at_ms < millis()) {
443  _servo_look_around_at_ms = millis() + random(FUN_MIN_PAUSE_MS, FUN_MAX_PAUSE_MS);
444  servo_set_to_left();
445  delay(500);
446  servo_set_to_right();
447  delay(800);
448  servo_set_to_center();
449  delay(300);
450  servo_set_to_left();
451  delay(100);
452  servo_set_to_center();
453  }
454 }

◆ kitt()

void CodeRacer::kitt ( )

Fun stuff - you know Knightrider...

Returns
nothing

Definition at line 459 of file CodeRacer.cpp.

460 {
461  if (millis() - _last_led_switched_at_ms > LED_SWITCH_MS) {
462  _last_led_switched_at_ms = millis();
463  if (_last_led_on >= 5) {
464  _led_count = -1;
465  }
466  else if (_last_led_on <= 0) {
467  _led_count = 1;
468  }
469  _last_led_on = _last_led_on + _led_count;
470  switch (_last_led_on) {
471  case 0:
472  set_leds_left_stop_frwd_right(LEDON, LEDOFF, LEDOFF, LEDOFF);
473  break;
474  case 1:
475  set_leds_left_stop_frwd_right(LEDON, LEDOFF, LEDOFF, LEDOFF);
476  break;
477  case 2:
478  set_leds_left_stop_frwd_right(LEDOFF, LEDON, LEDOFF, LEDOFF);
479  break;
480  case 3:
481  set_leds_left_stop_frwd_right(LEDOFF, LEDOFF, LEDON, LEDOFF);
482  break;
483  case 4:
484  case 5:
485  set_leds_left_stop_frwd_right(LEDOFF, LEDOFF, LEDOFF, LEDON);
486  break;
487  }
488  }
489 }