This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const els = 10000000; | |
console.log('setup -> ' + els); | |
const opts = { 0: 'Fail!', 1: 'Publish!', 2: 'Publish!' }; | |
let arr = []; | |
for ( let i = 0; i < els; ++i ) { | |
if ( Math.floor(Math.random() * 12) > 8 ) { | |
arr.push('good'); | |
} else { | |
arr.push('bad'); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void loop() { | |
// put your main code here, to run repeatedly: | |
long dist = msToCm(ping()); | |
if ( dist < 100.00 ) { | |
toneCounter = 0; | |
// 1 == min distance in cm | |
// 100 == max distance in cm | |
// 1500 == max frequency |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void loop() { | |
// put your main code here, to run repeatedly: | |
long dist = msToCm(ping()); | |
if ( dist < 100.00 ) { | |
toneCounter = 0; | |
// 1 == min distance in cm | |
// 100 == max distance in cm | |
// 1500 == max frequency |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define led 13 | |
#define buzzer 3 | |
#define echoPin A0 | |
#define pingPin 10 | |
int toneCounter = 0; | |
void setup() { | |
// put your setup code here, to run once: | |
Serial.begin(9600); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void blink(int blinks) { | |
for ( int i = 0; i <= blinks; i++ ) { | |
digitalWrite(led, HIGH); | |
delay(250); | |
digitalWrite(led, LOW); | |
delay(250); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
long ping() { | |
long duration; | |
// clear ping pin | |
digitalWrite(pingPin, LOW); | |
delayMicroseconds(2); | |
digitalWrite(pingPin, HIGH); | |
delayMicroseconds(10); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void playNote(int note, int duration, float rest) { | |
digitalWrite(led, HIGH); | |
tone(buzzer, note, duration); | |
delay((duration * rest)/2); | |
digitalWrite(led, LOW); | |
delay((duration * rest)/2); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void loop() { | |
delay(50); | |
// See if an object is in front of us | |
int distance = msToCm(ping()); | |
//Serial.println(distance); | |
if ( distance < detectionDistance ) { | |
// get a random song | |
playNote(NOTE_G5, 100, .1); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "Pitches.h" | |
/************************/ | |
/** PIN CONFIGURATIONS **/ | |
/************************/ | |
#define led 13 | |
#define buzzer 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void blink(int blinks) { | |
for ( int i = 0; i <= blinks; i++ ) { | |
digitalWrite(led, HIGH); | |
delay(250); | |
digitalWrite(led, LOW); | |
delay(250); | |
} | |
} |
NewerOlder