Skip to content

Instantly share code, notes, and snippets.

@zdila
Last active November 27, 2016 14:48
Show Gist options
  • Select an option

  • Save zdila/05ed1094f25b1e891f157729c869501b to your computer and use it in GitHub Desktop.

Select an option

Save zdila/05ed1094f25b1e891f157729c869501b to your computer and use it in GitHub Desktop.
Arduino Police Car
void setup() {
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
}
void loop() {
long m = millis();
tone(8, (1.0 + sin(m / 250.0)) * 300 + 1200);
int x = m % 800;
digitalWrite(3, x >= 0 && x < 100 || x >= 200 && x < 300 ? HIGH : LOW);
digitalWrite(4, x >= 400 && x < 500 || x >= 600 && x < 700 ? HIGH : LOW);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment