ID in line 31. Then we check whether the current distance is less than or
equal to the threshold value that belongs to the current LED. If yes, we change
the LED s color accordingly. Otherwise, we set its color to white.
Some Fun with Sensors
With an ultrasonic sensor, you can easily detect whether someone is nearby. This
automatically brings a lot of useful applications to mind. You could open a door
automatically as soon as someone is close enough, for example.
Alternatively, you can use advanced technology for pure fun. What about some Hal-
loween gimmicks, such as a pumpkin that shoots silly string whenever you cross an
a
invisible line?
It could be a nice gag for your next party, and you can build it using
the PING))) sensor.
a.
http://www.instructables.com/id/Arduino-controlled-Silly-String-shooter/
Connect the Arduino to your computer and upload the sketch we developed
in the previous section. Start the Chrome App and move your hand back and
forth in front of the PING))) sensor. The display on the screen will look exactly
like the display in a typical car.
Sensors are an exciting topic, and in this chapter you ve learned the basics
of working with both analog and digital sensors. In the next chapter, we ll
build on that foundation and connect the Arduino to an accelerometer to
create a motion-sensing game controller.
What If It Doesn't Work?
See
What If It Doesn t Work?, on page
all parts properly to the breadboard. Take special care with the PING))) and
the TMP36 sensors, because you haven t worked with them before. Make sure
you ve connected the right pins to the right connectors of the sensors.
In case of any errors with the software—no matter whether it s JavaScript or
Arduino code—download the code from the book s website and see whether
it works.
If you have problems with serial communication, double-check whether you ve
used the right serial port and the right Arduino type. Remember to adjust
the path to your Arduino s serial port in the first line of
whether the baud rate in the JavaScript code matches the baud rate you ve
used in the Arduino code.
59, and make sure that you ve connected
www.it-ebooks.info
What If It Doesn't Work?
97
dashboard.js
. Also check
report erratum
discuss
Need help?
Do you have a question about the Arduino Uno and is the answer not in the manual?