Skip to content

Instantly share code, notes, and snippets.

long getDistance() {
long duration, d1, d2, d3, cm;
// The sensor is triggered by a HIGH pulse of 10 or more microseconds.
// Give a short LOW pulse beforehand to ensure a clean HIGH pulse:
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(80); // was 10
digitalWrite(trigPin, LOW);
@gskielian
gskielian / Ultrasonic Sensor HC-SR04.ino
Last active December 19, 2015 18:49
this reads out the distance from an ultrasonic sensor
int trigPin = 3;
int echoPin = 5;
long duration;
long distance;
long cm;
void setup()
{
Serial.begin(9600); //this starts the talking
pinMode(trigPin, OUTPUT); //we will tell the
@gskielian
gskielian / CollisionLoadLevel.js
Created July 22, 2013 03:19
How to load a level upon collision.
#pragma strict
function OnTriggerEnter (col : Collider)
{
Application.LoadLevel(1); //loads level 1 when some object collides with this object's box-collider (added via the physics sub-menu)
}
@gskielian
gskielian / GetTheGist?
Created July 22, 2013 15:46
Example of a Gist
Some Code Here
@gskielian
gskielian / Mario.ino
Created August 1, 2013 21:44
Mario Theme in Arduino: )
tone(9,660,100);
delay(150);
tone(9,660,100);
delay(300);
tone(9,660,100);
delay(300);
tone(9,510,100);
delay(100);
tone(9,660,100);
delay(300);
@gskielian
gskielian / Freq2Arduino
Created August 1, 2013 21:50
freq to arduino
cat freq.txt | sed 's/ /,/g' | sed 's/[^0-9,d]//g' | sed 's/^,/tone(9,/g' | sed 's/$/);/g' | sed 's/d,/delay(/g' | sed 's/^);//g' >gist.txt
@gskielian
gskielian / Freq2Arduino
Created August 1, 2013 21:50
freq to arduino
cat freq.txt | sed 's/ /,/g' | sed 's/[^0-9,d]//g' | sed 's/^,/tone(9,/g' | sed 's/$/);/g' | sed 's/d,/delay(/g' | sed 's/^);//g' >gist.txt