Skip to content

2Y0A21 SENSOR

Jaume Olivé Petrus edited this page Aug 25, 2017 · 13 revisions

Specification

What Comments
Identifier 2Y0A21 Infrared sensor
Interface ADC
Provides distance centimeters
Properties none
Datasheet

Code

-- Attach sensor using an external ADC (ADS1115) / channel 0
s = sensor.attach("2Y0A21", adc.ADS1115, 0)

while true do
  print("distance: "..s:read("distance").." cm")
  tmr.delayms(500)
end
Clone this wiki locally