我可以从哪里开始使用可编程硬件?
一段时间以来,我一直渴望至少学习一点有关硬件编程的知识,并想在这里提出要求以获得一些起点。我是一位相当有成就的程序员,具有 Delphi 和 Objective-c 经验,但从未听过设备端口/中断(我什至不知道术语),更不用说对硬件进行编程了。
首先,我希望能够做的是,
- 购买一个带有 2,3 或 10 个按钮的简单套件
- 通过 USB 将设备插入我的电脑
- 监听设备并编写一些代码,以便在按钮按下时执行某些操作按下。
我认为这是一个很好的起点,有人知道如何购买硬件或者我如何开始这个吗?
I've had a desire to learn at least a tiny bit about programming hardware for quite some time now and thought I'd ask here to get some starting points. I am a reasonably accomplished programmer with Delphi and Objective-c experience but have never even listened to a device port / interupt (I dont even know the terminology) let alone programmed a piece of hardware.
To start with what I would like to be able to do is,
- Buy a simple bit of kit with 2,3 or 10 buttons
- Plug the device into my pc via USB
- Listen to the device and write some code to do something once the button is pressed.
I reckon this is a good place to start, anyone got pointers on hardware to buy or how I could start this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
我喜欢 Arduino,它易于使用、开源,还有一个很棒的社区!
很好上手,并且使用 C/C++ 的子集。
另外,还有很多可用的附加硬件,如 GPS、蓝牙、Wifi 等。
从您从包装盒中取出 Arduino 的那一刻起,我对 Arduino 的体验一直很好(并在 Windows / Mac / Linux 上安装免费编译器) ,构建您的第一个“草图”(Arduino 的项目或应用程序)。
制作应用程序很简单,您有一个在启动时调用的
Setup
方法,然后是一个在 Arduino 运行时循环的loop
方法。然后您所要做的就是将输入或输出连接到 Arduino 板上的引脚,告诉代码它们是什么,希望您能获得所需的输出。
Arduino 的另一件真正好的事情(我确信还有其他事情)是,您现在可以使用那些破旧的打印机,或者没有人想要的 2x CD-ROM,以及其他所有过时的技术。在服务器机房里能找到的东西真是太神奇了!
现在,我只从事一些小项目,比如插入液晶显示屏、读取室温以及类似的各种项目。但根据我所做的,我对 Ardunio 很满意,它为嵌入式编程提供了良好的基础,如果还不够,你可以随时做得更大!
我的2分钱!
I like the Arduino, easy to use, open source and a great community!
Good to get started with, and uses a subset of C/C++.
Also, has alot of addon hardware available, like GPS, Bluetooth, Wifi etc
My experiences with Arduino have been nothing but good, from the point you get it out of it's box (and install the free compiler on either Windows / Mac / Linux), to building your first 'sketch' (a project or application for the Arduino).
Making an application is easy, you have a
Setup
Method, which is called on startup, and then aloop
method which is looped while the Arduino is running.Then all you have to do is hook either inputs or outputs up to the pins on the Arduino board, tell the code what they are and hopefully you'll get the desired output.
One other really good thing about the Arduino (and others I'm sure) is that you now have a use for those old broken printers, or 2x CD-Rom's that no one wants, and every other little bit of out dated technology. It's amazing what you can find in a server room!
Now, I have only worked on small projects, like plugging in an LCD, and reading the room temp and various projects like that. But based on what I have done, I am happy with the Ardunio, it gives a good base to embedded programming and if it's not enough, you can always go bigger!
My 2 cents!
还有热门的 netduino,它使用 .NET Micro Framework 和 Microsoft Visual C# Express。我不知道这是否比 Arduino 更好,但它是另一种选择。
There's also the hot-off-the press netduino which uses the .NET Micro Framework and Microsoft Visual C# Express. I don't know that's it's better than the Arduino but it's another option.
为什么不从微处理器的 AVR 编程开始呢?是的,这可能有点太低了。但我知道很多人都是从它开始进行硬件编程的。你可以在这里找到一个编译器。 http://winavr.sourceforge.net/ 以及一个很好的教程:http://www.ladyada.net/learn/avr/
Why don't you start with AVR programming for microprocessors. Yeh it might be a bit too low level. but I know many people that have started with it for hardware programming. you could find a compiler here. http://winavr.sourceforge.net/ and a good tutorial here: http://www.ladyada.net/learn/avr/
上一张海报提到了 Arduino,但您还应该考虑 Teensy。基本都是一样的,只是价格稍微好一些。您还可以选择在“Arduino”模式或原始 AVR 模式下使用它。我不知道Arduino是否给你这两种选择。
有一个比较页面,您可以在其中看到 Teensy 有一些更好的硬件。内置 USB 赋予其更好的性能。
The previous poster mentioned the Arduino, but you should also consider a Teensy. It's basically the same thing, but price is a little better. You also have the option of using it in "Arduino" mode, or raw AVR mode. I don't know if Arduinos give you both options.
There is a comparison page where you can see the Teensy has some better hardware. The built-in USB gives it much better performance.
我绝对建议尝试各种微控制器。 Arduino 控制器很好,并且有一个 数量 < a href="http://www.arduinotutorials.com/" rel="nofollow noreferrer">教程。
但是,这不是您唯一的选择。在学校时,我使用 Microchip PIC,这对于业余爱好者来说也非常好。 PIC 的好处是我们的微控制器教科书支持它,所以我们在学习理论时可以看到应用程序。
I would definitely suggest trying out various microcontrollers. Arduino Controllers are nice and have a number of tutorials.
However, its not your only option. In school, I worked with Microchip PICs, which are also quite nice for the hobbyist scene. The nice thing about the PIC was that our microcontrollers textbook supported it, so we got to see the application as we were learning the theory.
如果我理解你的问题是正确的,那么你对嵌入式编程不感兴趣。您想要购买从一开始就可用的东西并通过 Windows 对其进行控制。
说到按钮,Windows 中没有太多可做的。这些是 HID 控件,Windows 会为您处理所有接口。那里没有什么太令人兴奋的。
在这种情况下,您可以抓住任何操纵杆并使用 DirectInput(DirectX 技术的一部分)与其交互。借助力反馈,您可以做一些很酷的事情。
一个更有趣的项目是购买一个 Wii 控件并编写一些有趣的应用程序。
看看这个网站,了解我的意思:
http://johnnylee.net/projects/wii/
由于 Windows 不支持 Wii 控制器,因此您确实需要在这里做一些工作:)
If I understand your question right, you are not interested in embedded programming. You want to buy something that works from the begining and control it from Windows.
When it comes to buttons, there is not much to do in Windows. These are HID controls and Windows handles all the interfacing for you. Nothing too exciting there.
In that case you can grab any Joystick and use the DirectInput (a part of the DirectX tech.) to interact with it. With force feedback you can do some cool stuff.
A more fun project would be to buy a Wii control and write some fun applicartions.
Look at this site to get some ideas of what I mean:
http://johnnylee.net/projects/wii/
Since Windows has no support for a Wii contrller, you really get to do some work here :)
我发现你喜欢 Delphi,所以你可以看看 AvrCo Multitasking Pascal for AVR。您可以在 http://www.e-lab.de 尝试。 MEGA8/88版本是免费的。有大量的驱动程序、模拟器、JTAG 在线调试器和编程器,具有所有标准设备的可视化功能(对于初创公司,您只需几个电阻即可制作一个简单的 LPT 编程器)。它还可以为所有 Arduino 设备制作程序,因为 AVR 就在其中。 Atmel 的 STK500 是一款很好的初学者板,带有 LED、开关和少量其他外围设备。如果您更喜欢开源,那么带有 GCC 的 WinAVR 可能是您的选择。
I see that you like Delphi, so you can take a look at AvrCo Multitasking Pascal for AVR. You can try it at http://www.e-lab.de. MEGA8/88 version is free. There are tons of drivers, simulator, JTAG online debugger and programmer with visualization of all standard devices (for a startup, you can make a simple LPT programmer with just a few resistors). It can also make programs for all Arduino devices out there, since AVR is in their hearth. Atmel's STK500 is a good beginner board, with leds, switches, and few other peripherals. If you prefer open source, then WinAVR with GCC could be your path.
正如已经提到的,Arduino 是一个不错的选择。社区很大而且很有帮助。好处是,如果您愿意,您可以通过使用 AVR micro 的 GCC 端口直接转换到“真正的”语言。在我最新的项目中,我这样做了——使用 Arduino 进行大部分原型设计,然后用 C 语言重新编写。
从按钮和 LED 开始是个好主意。在改装 Wii 之前,请先建立使用基本硬件的信心!
一些链接:
As already mentioned, Arduino is a good choice. The community is large and helpful. The nice thing is that you can transition right to a "real" language by using the GCC port for AVR micros, if you want. On my latest project I did this - prototype most of it with Arduino, then re-write it in C.
Starting with buttons and LEDs is a great idea. Build some confidence in working with basic hardware first, before modding the Wii!
Some links:
您已经编写的任何程序都与硬件交互,包括显示器、键盘、鼠标、扬声器等。获得一个简单的设置,让您的程序可以处理 USB 设备上的按钮,不会教您太多有关使用硬件的知识。这在一定程度上是一个问题,即您希望软件堆栈处于多低的位置,以及您希望了解软件结束时发生的情况的程度。
这是一本相对容易阅读的书,涵盖了欧姆定律和微处理器之间的所有内容,让您很好地了解整个系统的功能。
其他回复提到了 Microchip PIC 和 Atmel AVR,这两家公司都有丰富的应用说明,请查看他们的网站并通读。您可以购买上述的低成本评估板或其他回复中提到的 Arduino 之类的东西,以迫使自己学习基础知识。 如果您想了解有关 PC 硬件的更多信息,
您可以查看 Windows(下载 WinDDK)、Linux 甚至 DOS 下的一些简单设备驱动程序(例如打印机或串行端口)。在 PC 上的 DOS 等程序下进行编程可以相对轻松地与 PC 硬件交互,您可以使用打印机端口读取按钮等。
链接(我是新用户,所以无法直接链接):
www.amazon .com/Art-Electronics-Paul-Horowitz/dp/0521370957
www.digikey.com/
www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=2879
www.atmel.com/products/avr/
Any program you already write interacts with hardware, there's the monitor, keyboard, mouse, speaker etc. Getting a simple setup where your program can deal with buttons on a USB device will not teach you that much about working with hardware. It's partly a question of how low you want to go in the software stack and how much you want to learn about what happens at the point where the software ends.
Electronics". It's a relatively easy read and covers everything between Ohm's law and the microprocessor and will give you a good idea of what the complete system does.
Other replies mentioned Microchip PIC and Atmel AVR which are small and simple microcontrollers. Both companies have a wealth of application notes, check out their web site, read through some app notes. You can get low cost evaluation boards for the above or something like the Arduino mentioned in other replies. Consider designing and building your own board to force yourself to learn the basics. Find a friend who is an EE or serious hobbyist who wouldn't mind helping you with some tips.
If you want to learn more about PC hardware you can take a look at some simple device drivers (e.g. printer or serial port) under Windows (download the WinDDK), Linux or even DOS. Programming under something like DOS on a PC allows for relatively easy interaction with the PC hardware, you can use a printer port to read push buttons etc.
Links (I'm a new user so I can't link directly):
www.amazon.com/Art-Electronics-Paul-Horowitz/dp/0521370957
www.digikey.com/
www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=2879
www.atmel.com/products/avr/