Hackster is hosting Hackster Holidays, Ep. 6: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Monday!Stream Hackster Holidays, Ep. 6 on Monday!
Jimmy Huang
Created November 29, 2015

Sharp Infrared Distance Sensor - 11/30/15

.

BeginnerShowcase (no instructions)10,426
Sharp Infrared Distance Sensor - 11/30/15

Things used in this project

Story

Read more

Schematics

Wiring Schematic

Wiring Schematic

Code

Untitled file

C/C++
int sensorpin = 0;                 // analog pin used to connect the sharp sensor
int val = 0;                 // variable to store the values from sensor(initially zero)

void setup()
{
  Serial.begin(9600);               // starts the serial monitor
}
 
void loop()
{
  val = analogRead(sensorpin);       // reads the value of the sharp sensor
  Serial.println(val);            // prints the value of the sensor to the serial monitor
  delay(100);                    // wait for this much time before printing next value
}

Credits

Jimmy Huang

Jimmy Huang

16 projects • 9 followers

Comments