开发者

Arduino project using infrared sensor and usb communication

I am planning on doing a small arduino开发者_运维知识库 project and would like to know if what I'm thinking would work with a regular arduino board. I'm thinking of buying an Arduino Uno for my project, along with an IR LED and an IR sensor. So here's what I want to go with this:

I want to point the LED towards the sensor, so that the sensor is always detecting light. Then', I'll start "cutting" that light (say, with with my hand) several times. I want the arduino program to time the intervals between the times the light is "cut" and send these times to my computer via USB, so I can process this data.

I've seen many people talk about serial communication between an arduino board and a computer, but I'm not sure how that works. Will it use the same usb connector I use to upload programs to the board, or do I have to buy anything else?

EDIT: tl;dr: I guess my question, in the end, is twofold: 1) Am I able to "talk" to my computer using the built-in USB connector on the board, or is that used solely for uploading programs and I need to buy another one? and 2) Is this project feasible with an Arduino Uno board?

Thanks for the help!


Yes, your project is very feasible.

  1. You use the built in USB connector to both program the device and communicate with it. Check out some examples on the Serial Reference Page

  2. For reading the sensor, you'll want to use either a digital or analog input. For a digital input, you'll likely have to external components to control the light threshold, but it will provide a simple yes or no if something is in front of it. With an analog input, you can use a threshold in code to determine when your hand passes.

  3. Timing can either be done on device with the Millis() function or on the connected computer.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜